XSL:TEXT, CDATA and PHP5
by Pascal Opitz on October 20 2006, 07:53
Right, so I am applying disable-output-escaping="yes" on an xsl:text element containing some CDATA, but the output is still coming with escaped entities …
<xsl:text disable-output-escaping="yes">
<![CDATA[This is a <p> tag]]>
</xs:text>
This is actually a glitch in the PHP5 built in transformation engine, and the good news is that there is a fix for this. The predefined constant LIBXML_NOCDATA will fix this behaviour to the one you expect:
$xsl_dom->loadXML($xsl, LIBXML_NOCDATA);
or
$xsl_dom->load($xsl_file_location, LIBXML_NOCDATA);
Comments
by Solid on October 22 2006, 23:19 #
by Pascal Opitz on October 23 2006, 03:08 #
I just ran into this the other day. I found it a bit awkward that I told it to disable the output escaping… and it straight up didn’t.
by Dustin Diaz on October 25 2006, 01:54 #
by Nick Fitzsimons on October 29 2006, 10:51 #
by Nick Fitzsimons on October 29 2006, 10:57 #
by Pascal Opitz on October 29 2006, 12:21 #
I serve HTML (on the sites I produce for clients, I haven’t yet hacked WordPress to serve HTML on my own site) on the basis that it is the only content type that is properly supported in the real world. As I’m generating the markup using XSLT, it will be an easy matter at a later date to start serving XHTML: a change to the relevant parts of <xsl:output> – that is, doctype-public, doctype-system and method – is all that will be required. But until XHTML 1 is supported to the same extent as HTML 4.01, it makes more sense (to me) to serve HTML. It’s still a standard, after all :-)
It’s perhaps worthy of note in this context that Tim Berners-Lee this week said that “The attempt to get the world to switch to XML, including quotes around attribute values and slashes in empty tags and namespaces all at once didn’t work” when he announced a new W3C initiative to develop HTML further, rather than concentrating solely on XHTML: see http://dig.csail.mit.edu/breadcrumbs/node/166
by Nick Fitzsimons on October 29 2006, 12:47 #
haven’t tried this so far: Would a transformation with output type “html” and XHTML doctypes produce valid XHTML? Or would the type need to be changed to “xml” in order to get self closing image tags etc?
by Pascal Opitz on October 30 2006, 02:41 #