|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-23 11:01 UTC] roger4a45 at yahoo dot es
Description: ------------ ref 1: I try to build a XML using DOM extensions and then I want to output this one by using XSLT extensions. My XML is created dinamicaly using createElements / appendChilds as i will show below. If I use specials chars like ?? ?? i can see a warning when i make and saveXML from DOMDocument. echo $xmlDOMDoc->saveXML() Warning: output conversion failed due to conv error in d:\archivos de programa\apache group\Apache\htdocs\newnovoprint\test\v2.php on line 122 Warning: Bytes: 0xE9 0x73 0x20 0x50 in d:\archivos de programa\apache group\Apache\htdocs\newnovoprint\test\v2.php on line 122 Andres Poluk Andr ref2: If I try to use XSLT extensions when i make a TransformToXML() output is wrong. Andr??s is output as a Andr??. ref3: I check documentation and i didn't find any information about that problem. If I load same XML from a file and i use XSLT extensions that result is OK. In code example i put third easy examples i build to explain this possible bug. Reproduce code: --------------- XML I want to make (tested) known as v1.xml in third source. <?xml version="1.0" encoding="ISO-8859-1" ?> <TEST> <NAME>Andr??s Polim</NAME> </TEST> XSL I use v1.xsl (tested) <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/REC-html40"> <xsl:template match="TEST"> <xsl:value-of select="NAME"/><BR/> </xsl:template> </xsl:stylesheet> First Code ref: 1 <?php $xml = new DOMDocument('1.0', 'iso-8859-1'); $root = $xml->CreateElement("TEST"); $child = $xml->CreateElement("NAME","Andr??s Poluk"); $root->appendChild($child); $xml->appendChild($root); echo $xml->saveXML(); // <----- Error ?> Second Code ref: 2 <?php $xml = new DOMDocument('1.0', 'iso-8859-1'); $xsl = new DOMDocument; $xsl->load('v1.xsl'); $proc = new XSLTProcessor; $root = $xml->CreateElement("TEST"); $child = $xml->CreateElement("NAME","Andr??s Poluk"); $root->appendChild($child); $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml); ?> Third code ref: 3 (This one works ok) <?php $xml = new DOMDocument; $xsl = new DOMDocument; $proc = new XSLTProcessor; $xml->load('v1.xml'); $xsl->load('V1.xsl'); $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml); ?> Expected result: ---------------- ref1,ref2,ref3: Andr??s Poluk (A simple text) or <?xml version="1.0" encoding="ISO-8859-1"?> Andr??s Poluk Actual result: -------------- ref1: Warning: Bytes: 0xE9 0x73 0x20 0x50 in d:\archivos de programa\apache group\Apache\htdocs\newnovoprint\test\v2.php on line 122 Andres Poluk Andr ref2: Andr??. Poluk ref3: Andr??s Poluk PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 13:00:01 2025 UTC |
I found this one that solve problem. It's ref2 code correction: <?php $xml = new DOMDocument('1.0', 'utf-8'); //Change encoding to utf-8 $xsl = new DOMDocument; $xsl->load('v1.xsl'); $proc = new XSLTProcessor; $root = $xml->CreateElement("TEST"); $val = utf8_encode ('Andr?s Poluk'); //New Line $child = $xml->CreateElement("NAME",$val); $root->appendChild($child); $xml->appendChild($root); $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml); ?> Now, output is what i expected. Maybe it will be usefull to add a note in your php DOM