0

XML File

<article>
    <paragraph>
        Stack Overflow is a question and answer site for
        &lt;b&gt;professional&lt;/b&gt; and enthusiast programmers.
    </paragraph>
</article>

HTML output

Stack Overflow is a question and answer site for professional and enthusiast programmers.

Question:

I want to transform &lt;b&gt; to the HTML element <b> using XSLT. Please suggest any XSLT code.

nwellnhof
  • 32,319
  • 7
  • 89
  • 113
  • Please don't add thanks and hello messages, we'd like to see your question only. Thanks! :) – StackExchange User Jun 20 '13 at 19:50
  • Possible duplicate of [How to unescape XML characters with help of XSLT?](http://stackoverflow.com/questions/2463155/how-to-unescape-xml-characters-with-help-of-xslt?rq=1) – nwellnhof Jun 20 '13 at 20:19

1 Answers1

2

It's bad XML design, of course, to include an escaped XML document embedded in another document like this. But it happens all the time. If the escaped tags are HTML and you want to copy them direct to the output, then disable-output-escaping will sometimes do the trick - but not always, because it only works when you are serializing. If you run an XSLT transformation in Mozilla then the output HTML is rendered without ever being serialized, so disable-output-escaping has no effect. XSLT pros therefore tend to discourage its use.

The better approach is to reparse the text that contains escaped tags. There's no standard way of doing this until XSLT 3.0 (which has a parse-xml() function), but you can often do it using extension functions.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164