Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   [XPATH] Is this a valid query? (http://www.velocityreviews.com/forums/t168562-xpath-is-this-a-valid-query.html)

gfrommer@hotmail.com 01-11-2005 05:58 PM

[XPATH] Is this a valid query?
 
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


Martin Honnen 01-11-2005 06:25 PM

Re: [XPATH] Is this a valid query?
 


gfrommer@hotmail.com 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/

Joris Gillis 01-11-2005 06:29 PM

Re: [XPATH] Is this a valid query?
 
> /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 !

David Carlisle 01-12-2005 11:32 PM

Re: [XPATH] Is this a valid query?
 

the boolean operator is and not AND

David


All times are GMT. The time now is 06:33 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.