Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > [XPATH] Is this a valid query?

Reply
Thread Tools

[XPATH] Is this a valid query?

 
 
gfrommer@hotmail.com
Guest
Posts: n/a
 
      01-11-2005
Hello Everyone,

I'm writing a server in java, and I want the clients to pass me an
XPath query. I want the XPath queries to be in a specific format
though, I'm pretty sure it's valid but I want your help.

We have several -top level- documents that the user is allowed returned
to them from the query. We don't want them grabbing subchunks of the
XML without that being encased in one of the allowed top documents. For
example, "Person" is the name of one of our top level documents. Is
this query valid?

/Person[/Person/Name="MrCool" AND /Person/Age >42] .... that will
return all Person documents with name "MrCool" and Age > 42, correct?

My REAL question is if we can have very complex predicates in our
XPath, including ()'s to group the parameters, such as:

/Person[ ((/Person/Age > 10 AND /Person/Age < 25) OR
(/Person/Age > 30 AND /Person/Age < 35)) AND
((/Person/Name = "RustyShackleford") OR
(/Person/Name = "DaleGribble")) ]

Is the above query valid? Is there a limit to the length of a
predicate? Also, how do XPath statements (engines) feel about
multi-line XPaths like the one above? Are linebreaks allowed in XPath
statements?

Thanks everyone

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-11-2005


wrote:


> how do XPath statements (engines) feel about
> multi-line XPaths like the one above? Are linebreaks allowed in XPath
> statements?


The section
<http://www.w3.org/TR/xpath#exprlex>
in the XPath 1.0 specification says:
"For readability, whitespace may be used in expressions even though
not explicitly allowed by the grammar: ExprWhitespace may be freely
added within patterns before or after any ExprToken."
thus I think line breaks are allowed in XPath expressions
--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      01-11-2005
> /Person[/Person/Name="MrCool" AND /Person/Age >42] .... that will
> return all Person documents with name "MrCool" and Age > 42, correct?


If the xml looks like:
<root>
<Person>
<Name>MrCool</Name>
<Age>50</Age>
</Person>
</root>
then the Xpath is not quite correct. It should be something like this:

/Person[Name="MrCool" AND Age >42]


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Fiat W3C !
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      01-12-2005

the boolean operator is and not AND

David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not valid SSID name during setup using the wizard =?Utf-8?B?SE1WYWNhbmE=?= Wireless Networking 4 08-23-2005 05:38 PM
Enigmail - no valid OpenPGP data found Chuck Firefox 3 04-27-2005 09:20 PM
Enigmail - no valid OpenPGP data found Chuck Firefox 0 04-26-2005 06:41 PM
User Control - InvalidCastException: Specified cast is not valid Ajit ASP .Net 1 04-24-2004 09:28 PM
Valid file types Aschel Kritsos ASP .Net 1 11-14-2003 05:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57