Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with XPath query

=?Utf-8?B?RGlmZmlkZW50?=
Guest
 
Posts: n/a
#1: Mar 5 '07
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>

bruce barker
Guest
 
Posts: n/a
#2: Mar 5 '07

re: Help with XPath query


xquery is case sensitive, use "and"

-- bruce (sqlwork.com)

Diffident wrote:
Quote:
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!!!!
>
>
=?Utf-8?B?RGlmZmlkZW50?=
Guest
 
Posts: n/a
#3: Mar 5 '07

re: Help with XPath query



Thanks Bruce...that did the trick!

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

"bruce barker" wrote:
Quote:
xquery is case sensitive, use "and"
>
-- bruce (sqlwork.com)
>
Diffident wrote:
Quote:
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!!!!
>
Closed Thread