[Home] [By Thread] [By Date] [Recent Entries]
Hi Martynas,
I think I have a couple of possible solutions for you. Googling a bit gave me some info on differences in output when using libxslt with PHP. Apparently, PHP adds some things to the serialized output tree (teriible!) and it doesn't do a very good job with it. I got most of the information, summarized below, from the annotated PHP manual here: http://php.oregonstate.edu/manual/en/function.xsl-xsltprocessor-transform-to-xml.php 1. Getting the output with PHP intervening, but without any other meddling, try this: $proc->transformToURI($xml, 'php://output'); 2. Getting (almost?) correct XHTML, use this: $domTranObj = $xslProcessor->transformToDoc($domXmlObj); $domHtmlText = $domTranObj->saveXML(); 3. It is unclear whether that will or will not add the obnoxious CDATA into the script tags. If it still does so, you can try this classic (but ugly) workaround: <xsl:text disable-output-escaping="yes"> <script type="text/javascript"> ... here comes the normal text of the scripts .... </script> </xsl:text> or the following, if you want to be more strict XHTML: <xsl:text disable-output-escaping="yes">
<script type="text/javascript">
//<![CDATA[
... here comes the normal text of the scripts ....
// ]]>
</script>
</xsl:text>Bottom line is: the culprit that is causing all these problems is in PHP 5, not with libxslt! The people writing the PHP serializer deliberately added the CDATA sections to the output stream and did so in a non-conformant non-compatible manner. According to this post, there has been a bug report, which has been closed, but I couldn't find it: http://www.abasketfulofpapayas.de/2007/08/problem-with-libxslt.html HTH, Cheers, -- Abel Braaksma PS: if the mailer, or the htmlizer of this list escapes the <script..> as <script> note that I meant it to be &_lt;script..> in the example above, without the underscore. Martynas Jusevicius wrote: Oh, somehow I didn't think about it :) Here's what it says for 5.2.2 Win: XSL enabled libxslt Version 1.1.17 libxslt compiled against libxml Version 2.6.26 EXSLT enabled libexslt Version 0.8.13 I was part of that discussion (though briefly) and yes, I read it, but didn't find this information.
|

Cart



