Putting It All Together

 
xslt for dummies
Chapter 5 - XPath Espresso
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002
  

The following bulleted lists give you a sampling of the various relative and absolute location paths Ive talked about in this chapter.

Axis examples

  • chapter or child::chapter selects the chapter element children of the current node.

  • @ name or attribute::name selects all the name attributes of the current node.

  • .. or parent::node() selects the parent of the current node.

  • . or self::node() selects the current node, regardless of its type.

  • self::chapter selects the current node if it is a chapter element.

  • decendant::chapter selects all the chapter descendants of the current node.

  • descendant-or-self::page selects all the page element descendants of the current node and, if the current node is a page element, then include it as well.

  • ancestor ::page selects all the page element ancestors of the current node.

  • ancestor-or-self::page selects all the page element ancestors of the current node and, if the current node is a page element, then include it as well.

  • chapter/descendant::page selects the page descendants of the chapter element children of the current node.

Node test examples

  • * or child::* selects all the element children of the current node.

  • @* or attribute::* selects all the attributes of the current node.

  • text() or child::text() selects all the text node children of the current node.

  • node() or child::node() selects all the node children of the current node.

  • */page selects all the page grandchildren of the current node.

Predicate examples

  • chapter[1] or chapter[position()=1] selects the first chapter element child of the current node.

  • chapter[last()] selects the last chapter element child of the current node.

  • U following-sibling::chapter[1] selects the next chapter element sibling of the current node.

  • preceding -sibling::chapter[1] selects the previous chapter element sibling of the current node.

  • chapter[@level] selects all the chapter element children of the current node that have a level attribute defined.

  • chapter[not(@level)] selects all the chapter element children of the current node that dont have a level attribute defined.

  • chapter[@level='advanced'] selects all the chapter element children of the current node that have a level attribute with a value of advanced .

  • chapter[summary] selects all the chapter element children of the current node that have one or more summary element children.

  • chapter[2][@level] selects the second chapter element child of the current node if it has a level attribute defined.

  • chapter[@level][2] selects the second chapter element child of the current node that has a level attribute defined.

Absolute path examples

  • / selects the root node.

  • /descendant::chapter selects all the chapter elements in the same document as the current node.

  • /descendant::summary[12] selects the 12th summary element in the document.

  
 
 
2000-2002    Feedback


XSLT For Dummies
XSLT for Dummies
ISBN: 0764536516
EAN: 2147483647
Year: 2002
Pages: 148

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net