XSL Nodes

   



Traversing Trees

Map directions for an address in a city that has a grid layout are simple: they consist of some combination of north, south, east, and west. You start from your location (the 'context node') and move in one of four directions (although not always in a rectilinear fashion). Traversing an array is also simple: you search for predecessors or successors of the current element.

Tree traversal is more complex than traversing arrays, but it's facilitated by the features available in XSL. Instead of thinking in terms of successors and predecessors (as you would in an array or a linked list), think in terms of 'ancestors' (such as your parent), and 'descendants' (such as your children). When you are situated at a particular node in a tree, it's called the context node because the actions that you perform are relative to that node.

Observe that the set of all your descendants is a set of elements that is also a sub-tree of the XML document, with the current node as the root of the sub-tree. On the other hand, the set of all your ancestors is a set of elements is a sub-tree of the XML document whose root coincides with the root of the XML document, with the current node as a leaf node of the sub-tree. XPath gives you numerous ways (thirteen, in fact) of traversing an XML document, and they are discussed in the next section.



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

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