473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[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

Jul 20 '05 #1
3 1813


gf******@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/
Jul 20 '05 #2
> /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 !
Jul 20 '05 #3

the boolean operator is and not AND

David
Jul 20 '05 #4

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

Similar topics

1
by: Joshua Beall | last post by:
Hi All, I have a task that should be very simple but I'm running into trouble. All I want to do is query a document using XPath, and save the resulting XML in a string. Here's that I am trying...
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
3
by: IMS.Rushikesh | last post by:
Hi Friends, I need a XPath query, whcih ll return me subset of data.... check below xml stream <label id="MyExpenseDetails_lbl" xlink:role="terseLabel">Short Expense Details</label> <label...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
0
by: wjfang | last post by:
Hi all, I come across this problem. I have an XML file A.xml, which follows the schema A.xsd. Then I can use XSLT to transform A.xml to B.xml that follows the schema B.xsd. In my case,...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
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...
4
by: syed.akhlaq | last post by:
Hi, Does anyone know how can I validate XPath expressions using xsd schema? Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.