Getting to the Root of the Issue

 
xslt for dummies
Chapter 18 - Ten Most Confusing Things About XSLT
XSLT For Dummies
by Richard Wagner
Hungry Minds 2002
  

At first glance, you may naturally look at the following XML snippet and conclude that animals is the root node of this document tree:

 <animals> <cats> <tigers/> <lions/> <tabby/> </cats> <dogs> <collie/> <doberman/> </dogs> </animals> 

Although animals is the highest level element (known as the document element ), it is not the root node. The root node is a "built-in" node and automatically serves as the ancestor of all nodes in the document tree. You never actually see the root node show up in your documentits just there; a given. Therefore, in the preceding example, animals is a child of the root node.

To demonstrate , the following template rule uses / to retrieve the root node:

 <xsl:template match="/"> <!-- Do something --> </xsl:template> 

When run on the preceding XML snippet, the animals element is not returned, but the root above it in the tree hierarchy.

  
 
 
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