note 74909 added to function.dom-domdocument-loadxml

From: Date: Thu, 03 May 2007 15:44:57 +0000
Subject: note 74909 added to function.dom-domdocument-loadxml
Groups: php.notes 
Request: Send a blank email to php-notes+get-126149@lists.php.net to get a copy of this message
If you want to preserve greater-than and lower-than signs inside CDATA sections with XSL processing you have to use the LIBXML_NOCDATA option: Given this XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration="yes" /> <xsl:template match="/"> <script type="text/javascript"> <xsl:text disable-output-escaping="yes"> // Decorative Brackets: <![CDATA[// <<<<>>>> ]]> </xsl:text> </script> </xsl:template> </xsl:stylesheet> and this PHP: <?php $xml = new DOMDocument; $xml->load('dummy.xml'); $xsl1 = new DOMDocument; $xsl1->load('scripttest.xsl'); $xsl2 = new DOMDocument; $xsl2->load('scripttest.xsl', LIBXML_NOCDATA); $proc = new XSLTProcessor; echo "Normal Load:\n"; $proc->importStyleSheet($xsl1); echo $proc->transformToXML($xml); echo "LIBXML_NOCDATA Load:\n"; $proc->importStyleSheet($xsl2); echo $proc->transformToXML($xml); ?> You get the following output: Normal Load: <script type="text/javascript"> // Decorative Brackets: // &lt;&lt;&lt;&lt;&gt;&gt;&gt;&gt; </script> LIBXML_NOCDATA Load: <script type="text/javascript"> // Decorative Brackets: // <<<<>>>> </script> ---- Server IP: 217.160.72.57 Probable Submitter: 217.110.81.26 ---- Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-loadxml.php Edit -- https://master.php.net/note/edit/74909 Del: integrated -- https://master.php.net/note/delete/74909/integrated Del: useless -- https://master.php.net/note/delete/74909/useless Del: bad code -- https://master.php.net/note/delete/74909/bad+code Del: spam -- https://master.php.net/note/delete/74909/spam Del: non-english -- https://master.php.net/note/delete/74909/non-english Del: in docs -- https://master.php.net/note/delete/74909/in+docs Del: other reasons-- https://master.php.net/note/delete/74909 Reject -- https://master.php.net/note/reject/74909 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126149) next »