Reputation: 3451
I have an XML node containing escaped HTML. The output method for the stylesheet is HTML.
<ORDCNFMNT>Line 1 of text <BR /> Line 2 of text</ORDCNFMNT>
I'd like to turn "& lt;" and "& gt;" back into "<" and ">" to yield
<ORDCNFMNT>Line 1 of text <BR /> Line 2 of text</ORDCNFMNT>
Right now the template used to process this node just takes the node's value:
<xsl:template name="ordCnfmNtTmplt">
<xsl:value-of select="ORDCNFMNT"/>
</xsl:template>
What should I do instead?
Upvotes: 0
Views: 1121
Reputation: 126742
There is no <xsl:replace>
element in XSL, and the fn:replace()
XPath function is available only in XPath 2.0. It is possible to write an XSL template that will perform a string replacement for you, but in this case it isn't the correct solution.
Valid XML documents can't contain literal <
, >
or &
characters, and if you are transforming to another XML document then XSLT won't let you put them in.
If you are transforming to text output using <xsl:output method="text" />
then the entities will be translated for you automatically without you having to do it explicitly.
Either way XSLT will do the right thing without the need to make any changes.
Upvotes: 1