Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display XML in HTML files (XSLT)
<!--
While working with XSLT templates, I came across an interesting problem. I am using an XSLT template
to transform an XML file into HTML. However, for debugging purposes I need to see the original XML
and since the generation process is done on a web server (like Resin does), it is not easy to get it.
The solution: display the original XML file inside the output HTML itself. As it turns out, this was
not easy since it requires to change all "<" and ">" to use entities like "<" and ">". In XSLT,
the solution looks as follows (another solution would be to use JavaScript to escape this client-side)
-->
<xsl:template match="*">
<<xsl:value-of select="name()"/>>
<xsl:value-of select="text)"/>
<xsl:apply-templates/>
</<xsl:value-of select="name()"/>><BR/>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.