XPath Abbreviations Quick Reference

Table 61 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 61. XPath Abbreviations Quick Reference

Table 62 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 62. Abbreviations in XPath Expressions

Metals, Mining & Crude-Oil Production

It can be very dark and dreary in a mine. That's why metal, mining & crude-oil production are using Stylus Studio as their light when it comes to data integration. See which of these top companies are using Stylus Studio to show them the way to XML!

XQuery Tools Support for TigerLogic XDMS

Stylus Studio's integration with the TigerLogic XDMS XQuery processor, allowing you to execute advanced XQuery expressions directly against any TigerLogic XDMS instance.

DTD vs. Schema

Stylus Studio provides tools for working with both W3C XML Schema and DTD's - this tutorial explains what the differences are between the two, providing a technical comparison of DTD vs Schema.

Multi Channel Publishing

Multi channel publishing lets you go beyond single-source publishing of HTML and PDF to also generate simultaneously for non-document forms, such as to communicate with partners or drive spreadsheets.

Stylus Most Wanted

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-2007 All Rights Reserved.