The Identity Template – XSLT 2.0 on steroids
Identity templates are arguably one of the most important things you should know about XSLT. Identity templates are really useful if you want to change only a part of the XML input data. The idea is not to create a explicit node copy of each item. The output of the identity transform is the same as the input, except for CDATA elements and attribute orders. Additional templates are created to define the exceptions for the matched elements which should be modified. This is mandatory if:
- The Interface / XML structure changes
- Output enriched with rule results in additional nodes
- Non-redundant template code is a must-have
Example of a XSLT2 Identity Transform template:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@*|*|processing-instruction()|comment()"> <xsl:copy> <xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
From now on, other templates can match nodes which should be modified. For example we wish to remove all nodes with the name “Bill”:
<xsl:template match="Bill"/>
Because the template is empty, the node is removed in the output.
If multiple transformations are applied, XML pipelines are better (XProc, …). Projects under active development include QuiXProc and Tabular.
Experience with YED
A while ago I tried to find an alternative piece of modelling software for projects where M$-Visio is not the project standard and I’m free to choose the modelling software I use. Four years ago I found YED and I’ve never looked back. The latest versions support BPMN Graphs and can be used to model topologic network plans, a variety of UML Diagrams and much more.
It’s worth a try. Check out the Examples.