Basically I am using some XSLT to transform XML, is there a way for the XSLT to spit out the XML that is feeding it? Something like:
<xsl:echo-xml />
Basically I am using some XSLT to transform XML, is there a way for the XSLT to spit out the XML that is feeding it? Something like:
<xsl:echo-xml />
The following copies the full XML to the result tree:
<xsl:copy-of select="." />
If you want to send that to the "message output", you can just wrap this like that:
<xsl:message>
<xsl:copy-of select="."/>
</xsl:message>
Basically I am using some XSLT to transform XML, is there a way for the XSLT to spit out the XML that is feeding it? Something like:
The easiest and shortest way:
<xsl:copy-of select="/"/>
This outputs the current XML document.
<xsl:copy-of select="."/>
This outputs the subtree rooted by the current node.
However, XSLT programmers use mostly the following (identity rule):
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
When this is the only template in the stylesheet, the complete XML document on which the transformation is applied is output as result.
Using the identity rule is one of the most fundamental XSLT design patterns. It makes extremely easy such tasks as copying all nodes but specific ones for which a specific processing is performed (such as renaming deleting, modifying the contents, ..., etc)/