OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XML Encoding of XPath: Examples



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