Skip to content

Instantly share code, notes, and snippets.

@yakovsh
Last active January 17, 2016 16:00
Show Gist options
  • Save yakovsh/203bd841381b5f665608 to your computer and use it in GitHub Desktop.
Save yakovsh/203bd841381b5f665608 to your computer and use it in GitHub Desktop.
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