Link: Hail to the Victors: Don’t read XSLT before putting up the Christmas tree....
Always wonderful to get such detailed posts from Hail to the Victors. Hey, let's just shorten her name to Hail. That way if we see her in the hall we can just run after her shouting "Hail Hail" and fulfill two purposes: (1) Getting Krysta's attention; (2) Showing appropriate school spirit before the Rose Bowl. Now, on to a serious treatment of the usual high quality questions:
1) My first question is probably very basic, but nevertheless I continue to struggle with grasping the notion. Repeatedly, the book refers to the current node, but, I am confused as to what determines it? Is it just whatever element that you’re telling the template to match on? It also seems that there is a second current node when dealing with XPath expressions. On page 74, the book comments “the current node of these select patterns is not the same as the current node of the template rule’s match pattern.” Is the main idea that the current node, in whatever context it is being used, is just a starting point for the processor to begin reading the tree?
Using relative location steps, this interpretation is indeed the correct one.
2) My second question has to do with XPath. I
understand that the general formula for a location step is
axis::nodetest[predicate]. Is it a correct assumption to make that you
must understand what the entire tree looks like in order to know what
axis to list in the formula? Or, should I be thinking of this in terms
of the axis relative to the current node, in which case the only thing
I would need to know is the relationship of the selected nodes relative
to the current node?
Actually, both. If you are using absolute location steps, you need to know the whole tree. With relative ones, only the tree that occurs underneath the current node.
3) Thirdly, as I was reading the section
about template rules, I started wondering what purpose the xsl:copy
template serves in real life. I understand that its primary function is
to carry over the element tags, but what practical use does this ever
serve in a business sense? Can someone supply me with an example when
you would not want the content information and just the tags?
Sometimes you just want the element and will do something else with the contents, like convert it to an attribute.