I am looking for a XSL snippet that simply returns the XML unaltered. It sounds trivial but I can’t seem to find an example anywhere on the web. Any help out there?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In order to copy the complete XML document, it is necessary to have a template that matches the root. This might be:
<xsl:template match='/'>or
<xsl:template match='node()'>Then a single copying of the current node (the root node) is just sufficient:
<xsl:copy-ofselect=’.’/>So, one such complete transformation is:
Although this is probably the simplest such transformation, XSLT programmers use another one, widely known as the
identity transformationor theidentity rule:The reson the identity transformation is considered to be one the most fundamental XSLT design patterns and to be so massively used, is that by overriding this template rule with other, more specific templates, one can very easily perform a variety of operations that otherwise will be difficult. Examples are deleting a particular (set of) element(s) that have a specific name or satisfy some other condition, renaming particular elements, changing the namespace of particular elements, creating new children or siblings of particular elements, …, etc.
For more information and code snippets using the identity transformation, do look here.