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

XML Encoding of XPath: Examples

  • From: Wayne Steele <xmlmaster@h...>
  • To: xml-dev@l...
  • Date: Wed, 14 Mar 2001 23:27:33 -0800

descendant xml
I propose an optional XML Encoding for XPath expressions.
I just posted a DTD; here's some usage examples to help clarify things.

Questions/Comments/Errata welcome.

-Wayne Steele

======================

EXAMPLES:

======
child::para
=
<child name="para" />
======
child::*
=
<child />
======
child::text()
=
<child type="text" />
======
child::node()
=
<child type="node" />
======
attribute::name
=
<attribute name="name" />
======
attribute::*
=
<attribute />
======
descendant::para
=
<descendant name="para" />
======
ancestor::div
=
<ancestor name="div" />
======
child::chapter/descendant::para
=
<child name="chapter" />
<descendant name="para" />
======
child::*/child::para
=
<child />
<child name="para" />
======
/
=
<root />
======
/descendant::para
=
<root/>
<descendant name="para" />
======
/descendant::olist/child::item
=
<root/>
<descendant name="olist" />
<child name="item />
======
child::para[position()=1]
=
<child name="para">
   <eq>
      <function name="position" />
      <number>1</number>
   </eq>
</child>
======
child::para[position()=last()]
=
<child name="para">
   <eq>
      <function name="position" />
      <function name="last" />
   </eq>
</child>
======
child::para[position()=last()-1]
=
<child name="para">
   <eq>
      <function name="position" />
      <sub>
         <function name="last" />
         <number>1</number>
      </sub>
   </eq>
</child>
======
child::para[position()>1]
=
<child name="para">
   <gt>
      <function name="position" />
      <function name="last" />
   </gt>
</child>
======
child::para[attribute::type="warning"][position()=5]
=
<child name="para">
   <eq>
      <attribute name="type" />
      <literal>warning</literal>
   </eq>
   <eq>
      <function name="position" />
      <number>5</number>
   </eq>
</child>
======
child::chapter[child::title]
=
<child name="chapter" >
   <child name="title" />
</child>
======
child::*[self::chapter or self::appendix]
=
child>
   <or>
      <self name="chapter" />
      <self name="appendix" />
   </or>
</child>
======
id("foo")/child::para[position()=5]
=
<function name="id">
   <literal>foo</literal>
</function>
<child name="para">
   <eq>
      <function name="position" />
      <number>5</number>
   </eq>
</child>
======
substring("12345", 0 div 0, 3)
=
<function name="substring">
   <literal>12345</literal>
   <div>
      <number>0</number>
      <number>0</number>
   </div>
   <number>3</number>
</function>
======
//*[@href]
=
<root/>
<descendant-or-self type="node" />
<child>
   <attribute name="href" />
</child>
======
//foo[@color="blue"]/bar[1]/baz
=
<root/>
<descendant-or-self type="node" />
<child name="foo">
   <eq>
      <attribute name="color" />
      <literal>blue</literal>
   </eq>
</child>
<child name="bar">
   <eq>
      <function name="position" />
      <number>1</number>
   </eq>
</child>
<child name="baz" />
======
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


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.