[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
RE: [xml-dev] XPath to XML markup converter?
- From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Sat, 07 May 2011 16:11:22 -0400
At 2011-05-07 15:51 -0400, Costello, Roger L. wrote:
> > By "equivalent XML markup" do you mean XQueryX
>
>Can XQueryX represent any arbitrary XPath expression?
Yes, I believe it can. If not then there would be a bug in XQueryX.
>I would like a tool that converts any arbitrary XPath expression and
>the resulting XML markup isn't necessarily an "XQuery".
But it is, because XPath is a strict subset of XQuery, so you can use
the XQueryX vocabulary for all of XPath. Below is an example of an
entire XQuery query made up purely of an XPath expression. I don't
have a tool with which to translate this to XQueryX for you ... I'm
just trying to help point you in a useful direction.
It is a simple example, but it illustrates my point that XPath *is* XQuery.
Wait ... it says it here:
http://www.w3.org/TR/xquery/#id-introduction
"XQuery Version 1.0 is an extension of XPath Version 2.0. Any
expression that is syntactically valid and executes successfully
in both XPath 2.0 and XQuery 1.0 will return the same result in
both languages."
... so you don't have to take my word for it.
>For example, I may extract an XPath expression from the new XML
>Schema 1.1 assert element, and I would like the tool to generate XML
>markup which expresses the same semantics.
Why reinvent the wheel if XQueryX has all of XPath in its XML vocabulary?
. . . . . . . . . Ken
T:\ftemp>type roger.xml
<?xml version="1.0" encoding="UTF-8"?>
<roger>
<p this="yes">This is a para</p>
<p>This is another para</p>
<p this="no">This is the last para</p>
</roger>
T:\ftemp>type roger.xq
doc('roger.xml')/roger/p[not(@this='no')]
T:\ftemp>xquery roger.xq
<?xml version="1.0" encoding="UTF-8"?>
<p this="yes">This is a para</p>
<p>This is another para</p>
T:\ftemp>
--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]