tags:

views:

19

answers:

1

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&lt;br&gt;
    Second line
  </html_node>
</root_node>

And an 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 &lt;br&gt; to actually produce a <br> tag in the resulting html code. How can I achieve this? I prefer using the standard Java API:s.

A: 

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

Thorbjørn Ravn Andersen
Ahh, I knew that there should be an easy and obvious answer. Thanks!
davidi