Google
 

« How old is “Caller-ID”?         Sender-ID - A Tale of Open Standards and Corporate Greed? - Part I »

Display XML in HTML files

Posted August 30, 2004 – 3:26 pm by Yakov Shafranovich in Programming

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>

Tags:

Permalink | Trackback URL | This post has

  1. 2 Responses to “Display XML in HTML files”

  2. Instead you could view it thru view source. Processing is done in browser at client side and not at webserver

    Thanks

    By Anonymous on Sep 16, 2004

  3. XSLT processing is done server-side, which is what I had been dealing with.

    By netwizard on Sep 18, 2004

Sorry, comments for this entry are closed at this time.