Hari's Corner
Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and thenHTML inside XML - rendering with XSLT issue
Filed under:
Tutorials and HOWTOs by
Hari
Posted on Fri, Jul 6, 2007 at 20:09 IST (last updated: Wed, Jul 16, 2008 @ 20:39 IST)
<content>
which is used as formatting tags and not part of the XML.
Here's the XSLT file<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="index.xsl" ?> <review> <title>A sample review</title> <author>A sample author</author> <content> <p>This is the actual review content</p> <p>Hello World! How are you today?</p> </content> </review>
index.xsl
I wrote to render the above XML file
The above code will not render correctly because the<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h1>Hari's Reviews</h1> <hr /> <h2><xsl:value-of select="review/title"/> by <xsl:value-of select="review/author"/></h2> <xsl:value-of select="review/content"/> </body> </html> </xsl:template> </xsl:stylesheet>
<xsl:value-of select="review/content"/>
tag will strip the HTML tags (as they're considered to be actually XML tags) while returning the data.
The correct code will be: <xsl:copy-of select="review/content"/>
Update: The smart quotes problem in the code has been fixed.
Comments closed
The blog owner has closed further commenting on this entry.
No comments yet
There are no comments for this article yet.