Re: [xsl] Processing inner elements

Subject: Re: [xsl] Processing inner elements
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Sat, 30 Dec 2006 12:25:26 +0100
Guy wrote:
That's exactly the sort of construct that I was referring to. I guess that
my problem was trying to work out where to look for that sort of
information. For example, what search words would you throw at Google to try
and find pages holding that info?

Guy, in lieu of obviousness ;-) try google with "rename nodes xslt", "rename tags xslt" or any combination. The first hit (on my google: http://www.xml.com/pub/a/2000/06/07/transforming/index.html) is about it (yet I don't find its explanations all too well though, but it gives you some pointers).


An important thing to remember (we all went through that process): when using "copy-of", you cannot add additional control to the contents of what you copy, it will just copy exactly the contents (node tree(s)) of what you specify in the select-attribute. When using "copy" on the other hand, it will only copy the current node (be it text, an element, an attribute), but here you can specify the contents of that node: hence the "apply-templates", which recursively comes back in the same template.

Other rule of thumb (this one I have found hardest to learn) is: "understanding How Templates Work". The processor decides how to do it, you decide what the output should look like (you define the rules). And the important thing to remember is: the most specific rule will be used for any given element. In my post, the first template (with the "copy") is very generic and catches "all other nodes with no specific matches". The other three are specific matches (match for "break", "para" and "image") and define more specific rules for these elements. The processor will use these when it encounters the corresponding nodes in the source, because the rules are more specific.

There's much more to it, of course, and XSLT has quite a steep learning curve. But once you get the basics right, you can do wonders with it (and all the more with XSLT 2).

Cheers,
Abel

Current Thread