This example shows the base of almost any XSLT transformation and the most fundamental XSLT design pattern. Producing as output an XML document that is identical to the source XML document.
Source XML document:
<t>Hello, World!</t>
XSLT transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Result: When applying this transformation on any source XML document, the output is an XML document that is identical to the source XML document. In this case:
<t>Hello, World!</t>
Do note:
Using and overriding the identity rule is the most fundamental XSLT design pattern. This leads to simple, short and elegant solutions to fundamental tasks, such as deletion/insertion/renaming of elements, and a lot more.
The identity rule/template is the one published in the W3C XSLT 1.0 Specification