Php, Xml To Html Through Xslt Makes Html Inside Cdata Encoded
Solution 1:
I'm sure you don't have something like this in your XSLT:
<xsl:template match="content">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>
XSLT "understands" CDATA perfectly well. More exactly - it not concerned with CDATA at all, this is the task of the underlying XML DOM parser which makes a text value out of it.
From an XSLT point of view, there is no way of knowing whether the string
"<div>bla & bla</div>"
came out of
<xml><div>bla &amp; bla</div></div>
or
<xml><![CDATA[<div>bla & bla</div>]]></div>
CDATA is merely a serialization convenience. The resulting info set/DOM is the same. And unless you disable output escaping, XSLT correctly produces the following value from the above string:
<div>bla &amp; bla</div>
Which is the reason for the fact that you see HTML code on the rendered page.
Solution 2:
See if this helps. I'd put more here in the answer but I think the link does a better job explaining how to achieve such a transform result from XSLT using the LexEv XMLReader, which is a wrapper for the standard XMLReader used by XSLT and Saxon.
Post a Comment for "Php, Xml To Html Through Xslt Makes Html Inside Cdata Encoded"