|Chapter 18 - Ten Most Confusing Things About XSLT|
|XSLT For Dummies|
|by Richard Wagner|
|Hungry Minds 2002|
Always keep in mind that an XSLT processor doesnt read an XML document sequentiallyone tag at a timeas you or I do; instead, the processor treats the source like a tree-like structure of hierarchical information. Within that tree, relationships among the various parts dictate how the processor reads and navigates the document during the transformation process.
Each XML document has a main document element that contains all the other elements inside its open and close tags. An xsl:stylesheet element, for example, contains template rules and all other parts of an XSLT stylesheet, so it acts as the document element of an XSLT stylesheet. Child elements of the document element are the equivalent of the first-level branches of a tree. These child elements may also have children, much like smaller branches. The XSLT processor works its way through the entire tree until it retrieves each leaf and branch and assembles it based on this hierarchy.
Each leaf and branch in the document tree is called a node. Elements are the most common type of node that you work with, but there are actually seven different node types: element, attribute, namespace, processing instruction, comment, and text. With that in mind, an element node has children not only when it contains other elements, but also when it contains attributes and text.
If you want more information on document trees, check out Chapter 3.