This issue is similar to the one mentioned here how to unescape xml with xslt but slightly different as my text is coming from a processing instruction.
I have an instruction like this:
<?xm-mark data="<p>Here is the text</p>" ?>
And I would like to output the data part with the < unencoded. My attempt so far is:
<xsl:template match="processing-instruction('xm-mark')">
<mymark>
<xsl:value-of select="substring-before(substring-after(., 'data="'), '"')"
disable-output-escaping="yes" />
</mymark>
</xsl:template>
However, this gives me back the text as <p>. If I remove the disable-output-escaping=”yes”, i get back &lt; (double encoded as i would expect). Since I can’t put a value-of around the value-of in my template, any idea how i unescape the data?
This is what you get when you destroy markup by converting it to text.
Remember never to “architect” such horrible things.
Also, resorting to DOE is a sign of desperation and is not guaranteed to work at all (DOE is not a mandatory feature and some major XSLT 1.0 processors, such as the one used by FF don’t implement it).
So, what other alternative is there?
One possible solution is to write an extension function (there is no such standard function in XSLT/XPath version 1.0 and 2.0) that takes a string, parses it as XML and returns the resulting XML document. It will be used like that: