Help with XPath query

G

Guest

Hello All,

I am trying to construct an XPath query against an XML document, for a
requirement that I have. Below is the XML fragment:

<SUBMISSIONS>
<SUBMISSION YEAR="2004">
<MONTH NAME="JAN">10</MONTH>
<MONTH NAME="FEB">02</MONTH>
.
.
<MONTH NAME="DEC">78</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2005">
<MONTH NAME="JAN">03</MONTH>
<MONTH NAME="FEB">50</MONTH>
.
.
<MONTH NAME="DEC">27</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2006">
<MONTH NAME="JAN">34</MONTH>
<MONTH NAME="FEB">65</MONTH>
.
.
<MONTH NAME="DEC">22</MONTH>
</SUBMISSION>
<SUBMISSIONS>

If a user selects a time-period from 01-MAR-2005 to 31-DEC-2006, I have to
display month-wise counts for each of those months. i.e., I have to add March
of 2005 and March of 2006, April of 2005 and April of 2006 and so on and so
forth. and display the grand totals for individual months during that time
period. As part of this requirement, I wrote the following XPath query to get
the nodes for "NOV" from any of the years > 2005.

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005]/MONTH[@NAME='NOV']"

But what I really need is the time period from 2005 to 2006; and when I try
the below query to get the nodes between this time period, I get "invalid
token" error message:

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005 AND @YEAR <= 2006]/MONTH[@NAME='NOV']"

Is not this a valid Xpath query? Cannot I specify lower bound and upper
bound simultaneously in an Xpath query? If I give only one predicate it works
fine...

Help!!!!
 
G

Guest

Thanks Bruce...that did the trick!

I changed "AND" to "and" and it worked like a charm.

bruce barker said:
xquery is case sensitive, use "and"

-- bruce (sqlwork.com)
Hello All,

I am trying to construct an XPath query against an XML document, for a
requirement that I have. Below is the XML fragment:

<SUBMISSIONS>
<SUBMISSION YEAR="2004">
<MONTH NAME="JAN">10</MONTH>
<MONTH NAME="FEB">02</MONTH>
.
.
<MONTH NAME="DEC">78</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2005">
<MONTH NAME="JAN">03</MONTH>
<MONTH NAME="FEB">50</MONTH>
.
.
<MONTH NAME="DEC">27</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2006">
<MONTH NAME="JAN">34</MONTH>
<MONTH NAME="FEB">65</MONTH>
.
.
<MONTH NAME="DEC">22</MONTH>
</SUBMISSION>
<SUBMISSIONS>

If a user selects a time-period from 01-MAR-2005 to 31-DEC-2006, I have to
display month-wise counts for each of those months. i.e., I have to add March
of 2005 and March of 2006, April of 2005 and April of 2006 and so on and so
forth. and display the grand totals for individual months during that time
period. As part of this requirement, I wrote the following XPath query to get
the nodes for "NOV" from any of the years > 2005.

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005]/MONTH[@NAME='NOV']"

But what I really need is the time period from 2005 to 2006; and when I try
the below query to get the nodes between this time period, I get "invalid
token" error message:

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005 AND @YEAR <= 2006]/MONTH[@NAME='NOV']"

Is not this a valid Xpath query? Cannot I specify lower bound and upper
bound simultaneously in an Xpath query? If I give only one predicate it works
fine...

Help!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top