note 72519 added to function.xsl-xsltprocessor-transform-to-xml

From: Date: Mon, 22 Jan 2007 21:36:42 +0000
Subject: note 72519 added to function.xsl-xsltprocessor-transform-to-xml
Groups: php.notes 
Request: Send a blank email to php-notes+get-122043@lists.php.net to get a copy of this message
I noticed an incompatibility between libxslt (php4) and the transformation through XSLTProcessor. Php5 and the XSLTProcessor seem to add implicit CDATA-Section-Elements. If you have an xslt like <script type="text/javascript"> foo('<xsl:value-of select="bar" />'); </script> It will result in <script type="text/javascript"><![CDATA[ foo('xpath-result-of-bar'); ]]></script> (at least for output method="xml" in order to produce strict xhtml with xslt1) That brings up an error (at least) in Firefox 1.5 as it is no valid javascript. It should look like that: <script type="text/javascript">//<![CDATA[ foo('xpath-result-of-bar'); ]]></script> As the CDATA-Section is implicit, I was not able to disable the output or to put a '//' before it. I tried everything about xsl:text disable-output-escaping="yes" I also tried to disable implicit adding of CDATA with <output cdata-section-elements="" /> (I thought that would exclude script-tags. It didn't). The solution: <xsl:text disable-output-escaping="yes">&lt;script type="text/javascript"&gt; foo('</xsl:text><xsl:value-of select="bar" /><xsl:text disable-output-escaping="yes">'); &lt;/script&gt;</xsl:text> Simple, but it took me a while. ---- Server IP: 217.160.72.57 Probable Submitter: 217.247.190.15 ---- Manual Page -- http://www.php.net/manual/en/function.xsl-xsltprocessor-transform-to-xml.php Edit -- https://master.php.net/note/edit/72519 Del: integrated -- https://master.php.net/note/delete/72519/integrated Del: useless -- https://master.php.net/note/delete/72519/useless Del: bad code -- https://master.php.net/note/delete/72519/bad+code Del: spam -- https://master.php.net/note/delete/72519/spam Del: non-english -- https://master.php.net/note/delete/72519/non-english Del: in docs -- https://master.php.net/note/delete/72519/in+docs Del: other reasons-- https://master.php.net/note/delete/72519 Reject -- https://master.php.net/note/reject/72519 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122043) next »