php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32078 saveXML / XSLT TransformToXML bug?
Submitted: 2005-02-23 11:01 UTC Modified: 2005-02-23 12:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: roger4a45 at yahoo dot es Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.0.2 OS: Windows XP /Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: roger4a45 at yahoo dot es
New email:
PHP Version: OS:

 

 [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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-23 11:11 UTC] roger4a45 at yahoo dot es
Note: I see some chars from my explanation are bad. Characters have problems are accents like &agrave; (using html encoding) So, I want to output Andr&agrave;s Poluk.

In ref2: Output seeing IE Explorer source is: Andr&#x9CE0;Poluk (using same html encoding).
 [2005-02-23 12:22 UTC] roger4a45 at yahoo dot es
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
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 06:01:28 2025 UTC