[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: 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

RE:  XPath to XML markup converter?
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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.