Using escaped HTML tags in XML documents as HTML code after XSLT transformation
I have xml files with escaped HTML code in them, and I want to use this as real html tags in the html output after an XSLT transformation. Some example XML may look like this:
<root_node>
<html_node>
First line<br>
Second line
</html_node>
</root_node>
And a开发者_JS百科n XSLT stylesheet could look like this:
<xsl:stylesheet>
<xsl:output method="html"/>
<xsl:template match="root_node">
<html>
<body>
<xsl:value-of select="html_node"/>
</body>
</html>
</xsl:template>
<xsl:template match="*"/>
</xsl:stylesheet>
I want the <br> to actually produce a <br> tag in the resulting html code. How can I achieve this? I prefer using the standard Java API:s.
You are looking for the disable-output-escaping attribute to xsl:value-of
<xsl:value-of select="expression" disable-output-escaping="yes|no" />
http://www.w3schools.com/xsl/el_value-of.asp
精彩评论