XPath Abbreviations Quick Reference

Table 73 defines the abbreviations you can use in XPath expressions:

Abbreviation
Description
No axis is specified in a location step.

The child axis is assumed. For example, the following two XPath expressions both return the para children of chapter children of the context node:

chapter/para
               
child::chapter/child::para
               

            
@

The attribute axis. For example, the following two XPath expressions both return para children of the context node that have type attributes with a value of warning:

para[@type="warning"]
               
child::para[attribute::type="warning"]
               

            
//
The descendant-or-self axis. For example, the following two XPath expressions both return all para descendants of the context node:
//para
               
/descendant-or-self::node()/child::para
               

            
However, it is important to note that the following two expressions are not equivalent:
/descendant::para[1]
               
//para[1]
               

            
The first expression selects the first para element that is a descendant of the context node. The second expression selects each para descendant that is the first para child of its parent.
.
A single dot is the abbreviation for self::node(). This selects the context node. For example, the following two XPath expressions both return all para descendants of the context node:
.//para
               
self::node()/descendant-or-self::node()/child::para
               

            
..
A double dot is the abbreviation for parent::node(). This selects the parent of the context node. For example, the following two XPath expressions both return the title children of the parent of the context node:
../title
               
parent::node()/child::title
               

            
Table 73. XPath Abbreviations Quick Reference

Table 74 shows examples of abbreviations in XPath expressions

Example
Description
para
Selects the para children of the context node
*
Selects all element children of the context node
node_test
Evaluates all children of the context node and returns those that test true for the particular node_test
*/para
Selects all para grandchildren of the context node
para[1]
Selects the first para child of the context node
para[last()]
Selects the last para child of the context node
/doc/chapter[5]/section[2]
Selects the second section of the fifth chapter of the doc child of the context node
para[@type="warning"]
Selects para children of the context node that have type attributes with a value of warning
para[@type="warning"][5]
Selects the fifth para child of the context node that has a type attribute with a value of warning
para[5][@type="warning"]
Selects the fifth para child of the context node if that child has a type attribute with a value of warning
chapter[title]
Selects the chapter children of the context node that have one or more title children
//para
Selects all para descendants of the document root
chapter//para
Selects all para descendants of chapter children of the context node
//olist/item
Selects all item elements that have olist parents
.
Selects the context node
.//para
Selects the para descendants of the context node
..
Selects the parent of the context node
@*
Selects all attributes of the context node
@name
Selects the name attribute of the context node
../@name
Selects the name attribute of the parent of the context node
Table 74. Abbreviations in XPath Expressions

XML Processing

Learn how to simplify XML Processing using Stylus Studio XML Pipeline, the easiest way to visually design and deploy virtually any XML processing tasks.

Biotechnology & Pharmaceuticals

Leading biotechnology & pharmaceuticals companies take Stylus Studio when they are feeling under the weather. Come see for yourself how Stylus Studio can be a pick me up for your biotechnology or pharmaceutical company.

Using XSLT Templates

Using XSLT Templates is an online video demonstration of the Stylus Studio XSLT designer. See just how easy it is to create, apply and match XSLT templates to your XML data to create beautiful HTML layouts for XML content publishing applications.

Investments and Financial Companies That Use Stylus Studio

Stylus Studio provides XML tools & components to leading investment and financial companies! See which top investment and financial companies are banking on Stylus Studio 2006 to simplify their dollars and cents.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member