Several people have asked me about the following XSLT transform, which I use to start every XML-to-XML stylesheet:

The identity transform in XSLT

What does it do? Nothing useful like this. It just copies all the XML input to the output using recursion. (Think about axes when you look at those XPaths: attributes are not children.)  The identity transform itself is from section 7.5 of the XSLT specification.

It’s useful when you add more templates that match nodes more specifically. It’s a great way to filter or edit large (ish) XML documents for little programming effort, especially over large numbers of documents when combined with some command-line scripting.

(And I just discovered the first things I don’t like about WordPress: escaping works badly, and you can’t upload XSLT in standard config…)

Comments are closed.