473,698 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xquery help

Greetings.

I can't invest a large amount of time into this, but it would be very helpful
if I could do this.

I have a directory full of xml files I'd like to be able to query to find out
things like:

find all elements of type "<table" that contain as subelements (elements of
type "row" that have attributes of type "lookup" which have value
"timelookup ")

return all the elements of type "row" with their attribute "size" (even if the
size attribute is not specified I'd like to know that) that are in elements
of type "table" where the table has attribute "virtual" not null (or perhaps
null, i.e. not set or specified)

I tried downloading saxon and galax.
I could not get saxon to run (yes, probably my own inability/impatience).
I got galax to run, but can't figure out how to get some simple queries to
work.
I'm still hammering away on the documentation, but this is a "do it in my
spare time" project, and I'd really appreciate any recommendations or
pointers.

Am I using the wrong tool(s)?
Finally, I'd like to be able to format the output to make it possibly more
useful, even as input to another query??..??

Thanks again, in advance if that is not too presumptuous

Jeff Kish
Jul 20 '05 #1
7 2063
Jeff Kish wrote:
find all elements of type "<table" that contain as subelements (elements of
type "row" that have attributes of type "lookup" which have value
"timelookup ")

return all the elements of type "row" with their attribute "size" (even if the
size attribute is not specified I'd like to know that) that are in elements
of type "table" where the table has attribute "virtual" not null (or perhaps
null, i.e. not set or specified)
Each of these tasks should take an experienced
developer less than one hour.
I tried downloading saxon and galax.
Why did you do this ?
Did you expect these tools to be easy to learn ?
Am I using the wrong tool(s)?
Use a language that you already know.
Even bash has an XML extension today.
Finally, I'd like to be able to format the output to make it possibly more
useful, even as input to another query??..??


This is no problem .. _if_ you know your tool.
Jul 20 '05 #2
Jeff Kish <je*******@mro. com> wrote:
Greetings.

I can't invest a large amount of time into this, but it would be very helpful
if I could do this.

I have a directory full of xml files I'd like to be able to query to find out
things like:

find all elements of type "<table" that contain as subelements (elements of
type "row" that have attributes of type "lookup" which have value
"timelookup ")

return all the elements of type "row" with their attribute "size" (even if the
size attribute is not specified I'd like to know that) that are in elements
of type "table" where the table has attribute "virtual" not null (or perhaps
null, i.e. not set or specified)
Hmm, you can determine if such condition exists in a XML file. But,
what do you want to do once you find out? If you want a printout of the
entire node, then SAX-type parser (ie. Expat) may not be the best tool.

Or, you have to parse the files in two-pass fashion, once for slicing
out every nodes, and another for testing if condition is true.

I tried downloading saxon and galax.
I could not get saxon to run (yes, probably my own inability/impatience).
I got galax to run, but can't figure out how to get some simple queries to
work.
I'm still hammering away on the documentation, but this is a "do it in my
spare time" project, and I'd really appreciate any recommendations or
pointers.

Am I using the wrong tool(s)?
Finally, I'd like to be able to format the output to make it possibly more
useful, even as input to another query??..??

Thanks again, in advance if that is not too presumptuous

Jeff Kish


--
William Park <op**********@y ahoo.ca>
Open Geometry Consulting, Toronto, Canada
Jul 20 '05 #3
On Thu, 14 Oct 2004 18:24:20 +0200, Jürgen Kahrs
<Ju************ *********@vr-web.de> wrote:
Jeff Kish wrote:
find all elements of type "<table" that contain as subelements (elements of
type "row" that have attributes of type "lookup" which have value
"timelookup ")

return all the elements of type "row" with their attribute "size" (even if the
size attribute is not specified I'd like to know that) that are in elements
of type "table" where the table has attribute "virtual" not null (or perhaps
null, i.e. not set or specified)
Each of these tasks should take an experienced
developer less than one hour.


First of all, thankyou for your kind reply (no sarcasm intended).. I realize
that time is precious and I appreciate yours and the other posters'.
I have some experience.. but not in using XML libraries/objects.. That's why
I'm asking for a bit of advice since I can't pour lots of time into this task
(which fortunately does not sound too complicated). It would take me a half
day or day (which translates into a lot of spare time-days) to figure out how
to load/write a program that just accesses, say, JDOM.
I tried downloading saxon and galax.
Why did you do this ?
Did you expect these tools to be easy to learn ?

I need something that can query XML in a similar fashion to SQL, and I had
heard XQuery was a good target, so I googled around on XQUERY and commandline.

I was hoping for a gentle learning curve, since the things I want to do are
not too difficult I figured an hour or two to get a tool installed and
running, and an hour or two to figure out how to do these simple queries.

I ended up not being able to get the saxon tool to run (I really don't know
java very well.. it could not find some classes etc), so I left off after
about an hour or so and went to galax.

After about an hour I had the galax tool up and available, so I started
through some of the tutorials. It took another three hours to find some
beginner/clear tutorials, so I'm almost at the point where I may be able to
submit some queries.

I figured at the time I posted, that someone might offer some advice for a
tool that would be better suited to my limits of time and ability.
Am I using the wrong tool(s)?


Use a language that you already know.
Even bash has an XML extension today.

I would like to do this from the command line. Though I know a little java and
even more c++, it has been a while since I did anything with XML in them.
Finally, I'd like to be able to format the output to make it possibly more
useful, even as input to another query??..??


This is no problem .. _if_ you know your tool.


Jeff Kish
Jul 20 '05 #4
On 14 Oct 2004 16:22:40 GMT, William Park <op**********@y ahoo.ca> wrote:
Jeff Kish <je*******@mro. com> wrote:
Greetings.

I can't invest a large amount of time into this, but it would be very helpful
if I could do this.

I have a directory full of xml files I'd like to be able to query to find out
things like:

find all elements of type "<table" that contain as subelements (elements of
type "row" that have attributes of type "lookup" which have value
"timelookup ")

return all the elements of type "row" with their attribute "size" (even if the
size attribute is not specified I'd like to know that) that are in elements
of type "table" where the table has attribute "virtual" not null (or perhaps
null, i.e. not set or specified)
Hmm, you can determine if such condition exists in a XML file. But,
what do you want to do once you find out? If you want a printout of the
entire node, then SAX-type parser (ie. Expat) may not be the best tool.


Well, I figure if I can get at least the elements and their id's, I could get
some use out of that. The worst case scenario is I could load up the files of
interest in an editor and search for those id's and then examine the XML.
Or, you have to parse the files in two-pass fashion, once for slicing
out every nodes, and another for testing if condition is true.

Not sure.. but I finally have galax 3.5 up and running, and it appears to be
promising. Eventually I'd like to be able to tie java code, database contents
and xml files in some sort of process where I can find situations where things
are used different ways.. for example

find out what files use a certain attribute in a certain element tree and find
out where in the database it exists as data, or where in java code it is
referenced in a given function call.

I tried downloading saxon and galax.
I could not get saxon to run (yes, probably my own inability/impatience).
I got galax to run, but can't figure out how to get some simple queries to
work.
I'm still hammering away on the documentation, but this is a "do it in my
spare time" project, and I'd really appreciate any recommendations or
pointers.

Am I using the wrong tool(s)?
Finally, I'd like to be able to format the output to make it possibly more
useful, even as input to another query??..??

Thanks again, in advance if that is not too presumptuous

Jeff Kish


Jeff Kish
Jul 20 '05 #5
Jeff Kish wrote:
Well, I figure if I can get at least the elements and their id's, I could get
some use out of that. The worst case scenario is I could load up the files of
interest in an editor and search for those id's and then examine the XML.
Before you do that, try using any scripting language.
I don't like Perl, but I think for your problem Perl
with a suitable XML module might be the easiest solution.
Not sure.. but I finally have galax 3.5 up and running, and it appears to be
promising. Eventually I'd like to be able to tie java code, database contents
and xml files in some sort of process where I can find situations where things
are used different ways.. for example


I am surprised how many tools you are willing to employ
in this rather simple task. Again: a scripting language
might do it much easier.

I am currently working on such an extension for the
GNU Awk scripting language and I bet each of your
problems can be solved with 20 lines of code. But I
cannot offer you a proper binary distribution or
documentation yet. So, at the moment Perl, Python
or bash might be best.
Jul 20 '05 #6
Jeff Kish <je*******@mro. com> wrote:
On 14 Oct 2004 16:22:40 GMT, William Park <op**********@y ahoo.ca>
wrote:
Jeff Kish <je*******@mro. com> wrote:
Greetings.

I can't invest a large amount of time into this, but it would be
very helpful if I could do this.

I have a directory full of xml files I'd like to be able to query
to find out things like:

find all elements of type "<table" that contain as subelements
(elements of type "row" that have attributes of type "lookup"
which have value "timelookup ")

return all the elements of type "row" with their attribute "size"
(even if the size attribute is not specified I'd like to know that)
that are in elements of type "table" where the table has attribute
"virtual" not null (or perhaps null, i.e. not set or specified)


Hmm, you can determine if such condition exists in a XML file. But,
what do you want to do once you find out? If you want a printout of
the entire node, then SAX-type parser (ie. Expat) may not be the best
tool.


Well, I figure if I can get at least the elements and their id's, I
could get some use out of that. The worst case scenario is I could
load up the files of interest in an editor and search for those id's
and then examine the XML.

Or, you have to parse the files in two-pass fashion, once for slicing
out every nodes, and another for testing if condition is true.

Not sure.. but I finally have galax 3.5 up and running, and it appears
to be promising. Eventually I'd like to be able to tie java code,
database contents and xml files in some sort of process where I can
find situations where things are used different ways.. for example

find out what files use a certain attribute in a certain element tree
and find out where in the database it exists as data, or where in java
code it is referenced in a given function call.


Do it manually using editor. It's the least time consuming approach.

However, for scripting approach...

I'm familiar with Expat (SAX-style) parser. Determining if certain
condition is true is the easy part. If I understand you right, you then
want to print out the entire scope of element, ie.
<table>
... <row lookup="timeloo kup">...</row> ...
</table>

And, I'm saying that it's difficult to do this with SAX-style parser,
because you have go back up to <table>, then jump forward to </table>.
Parser does not jump around; it only goes forward, calling callback
functions as it encounters different XML structures. This means that
you reached the end of 'table' element, only when you encounter </table>
tag. To print out all content since the last <table> tag, you have to
store the content manually. Pain.

Two-pass solution is easier. First, cut/slice your file based on
<table>...</table>
assuming it's not nested. Then, test each 'table' section if your
condition exist. If so, print the whole section.

Use any scripting language. I recommend
- Awk with Expat parser,
- Bash with Expat parser (http://freshmeat.net/projects/bashdiff/)

--
William Park <op**********@y ahoo.ca>
Open Geometry Consulting, Toronto, Canada
Jul 20 '05 #7
On Thu, 14 Oct 2004 09:58:33 -0400, Jeff Kish <je*******@mro. com> wrote:
Greetings.

I can't invest a large amount of time into this, but it would be very helpful
if I could do this.

I have a directory full of xml files I'd like to be able to query to find out
things like:

find all elements of type "<table" that contain as subelements (elements of
type "row" that have attributes of type "lookup" which have value
"timelookup" )

return all the elements of type "row" with their attribute "size" (even if the
size attribute is not specified I'd like to know that) that are in elements
of type "table" where the table has attribute "virtual" not null (or perhaps
null, i.e. not set or specified)

I tried downloading saxon and galax.
I could not get saxon to run (yes, probably my own inability/impatience).
I got galax to run, but can't figure out how to get some simple queries to
work.
I'm still hammering away on the documentation, but this is a "do it in my
spare time" project, and I'd really appreciate any recommendations or
pointers.

Am I using the wrong tool(s)?
Finally, I'd like to be able to format the output to make it possibly more
useful, even as input to another query??..??

Thanks again, in advance if that is not too presumptuous

Jeff Kish

Hi.
I've made progress in case anyone else is trying this also.
I downloaded galax (3.5.. 4.0 does not have windows binaries yet)
and spent a few hours going through some useful XQuery tutorials I found
elsewhere.

I may look into Qexo to compile the xqueries into java to have ones I use over
and over again into "binaries".

Eventually I'll investigate pushing the xml into a database so I can cross
query xml/database/code, or I'll figure out how to use xquery against a
database also.

Jeff

Jeff Kish
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1425
by: Benjamin G. Jones | last post by:
I am having a very basic problem with XQuery. I want to use an XQuery API in Java (either Saxon or Qexo), and I have an XQuery expression that works as expeced from the command line if I specify a filename before the xpath expression. What I want to know is this: If I want to use Qexo's gnu.xquery.lang.XQuery.eval() or Saxon's QueryExpression.evaluate(), how do I specifiy the input in the Xquery statement?
4
4122
by: Jeff Kish | last post by:
Hi. I see it appears that xquery is case senstitive for looking for particular attribute values etc. Is there a standard way around this? Say I want to see all nodes with an attribute valued "copyright" or some such? Finally, is there a "like" function similar to sql? I perused the docs and did not see anything, but was wondering if I missed it, or if there is a way around it? Maybe I need to write a user function?
0
2171
by: Tony Lavinio | last post by:
Dear Stylus Studio Friends, The new year is scarcely one month old, but we already have lots to report! For starters, there's Stylus Studio 6 Release 2. The latest release of Stylus Studio boasts literally hundreds of product enhancements, and is available now for free trial download. We're also proud to present our interview with Dr. Daniela Florescu, editor of the XQuery specification. Read this month's Stylus Scoop and learn about...
0
1479
by: Tony Lavinio | last post by:
Dear comp.text.xml community, Microsoft recently announced that they are dropping XQuery from their next release of the .NET Framework, 2.0 (Whidbey). Since Microsoft ships .NET Framework only every 3 or so years, cutting XQuery from Whidbey means that the next opportunity for XQuery to find its way into .NET Framework won't be until around 2009, and even then it's far from a sure thing. That's why it's so important that the community...
1
1346
by: FBS | last post by:
Hi everybody, I wonder if somebody could help me with this issue. I would like to rum some XQuery codes aginst my XML files and since I'm quite new in this area I'm not sure what to do. It is not complicated ( I have even seen some XQuery examples on the Web ) just listing the values for some elements for instance. But what I need to know is, first of all, if I need to download anything?
0
2301
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies (http://www.datadirect.com), the software industry leader in standards-based components for connecting applications to data and an operating unit of Progress Software Corporation, today announced the release of DataDirect XQuery(TM), the first embeddable...
2
1752
by: BK | last post by:
I am working on system that will have a cataloging component which would essentially be a Folder/File structure. So far I have coded the Iteration over a selected folder and am displaying the data/structure in a TreeView (VB.NET 2005). I then serialize the Treeview and store the serialized XML in a SQL 2005 XML Column. I can also retrieve an entire XML (one record, that is) and (re) rebuild the TreeView by de-serializing. Never...
2
4334
by: tammo.mueller | last post by:
Hi, I'm trying to execute a xquery statement and I get always errors. It seems that only the prolog section is giving me errors. If I want to declare a namespace the xquery processor is coming up with an "unexpected token" error. The same error appears if I just set the version. The xquery statement itself is working without prolog, but I get no results because of the missing namespace.
5
3094
by: CK | last post by:
I have the following XML in an XML column in a SQL 2005 Database. <DeliveryList xmlns="http://schemas.adventure-works.com/DeliverySchedule"> <Delivery SalesOrderID="43659"> <CustomerName>Steve Schmidt</CustomerName> <Address>6126 North Sixth Street, Rockhampton</Address> </Delivery> <Delivery SalesOrderID="43660"> <CustomerName>Tony Lopez</CustomerName> <Address>6445 Cashew Street, Rockhampton</Address> </Delivery>
4
2480
by: Pascal Sartoretti | last post by:
Hello, I want to process big files (e.g. 100 MB) with XQuery. Are there XQuery processors that work in a "SAX-like" way (and not DOM-like), i.e. which don't assume that they have everything in memory ? Thanks for any help Pascal
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.