#29623 [Opn->Bgs]: XSLTProcessor don't process 'omit-xml-declaration' in 'xsl:output'
| From: | chregu@php.net | Date: | Thu, 12 Aug 2004 06:25:43 +0000 |
| Subject: | #29623 [Opn->Bgs]: XSLTProcessor don't process 'omit-xml-declaration' in 'xsl:output' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64467@lists.php.net to get a copy of this message | ||
ID: 29623
Updated by: chregu@php.net
Reported By: x-penguin at tut dot by
-Status: Open
+Status: Bogus
Bug Type: XSLT related
Operating System: Linux
PHP Version: 5CVS-2004-08-12 (dev)
New Comment:
transformToDoc always looses special XSLT formatting options (like
omit-xml-declaration, indent, method, etc), because the returned
Document is a simple DomDocument with no such information.
Use
$string = $proc->transformToXml($xml);
print $string;
to achieve what you want
Previous Comments:
------------------------------------------------------------------------
[2004-08-12 02:28:20] x-penguin at tut dot by
Description:
------------
PHP Version 5.1.0-dev, configure with:
'./configure' '--prefix=/usr/' '--with-apxs2'
'--with-gettext'
'--with-iconv' '--with-mysql' '--enable-mbstring=ru'
'--enable-mbregex'
'--enable-mbstr-enc-trans' '--disable-short-tags' '--with-xsl'
'--with-libxml' '--without-sqlite' '--enable-soap'
libxslt Version 1.1.8
libxml Version 2.6.11
libexslt Version 1.1.8
apache 2.0.48
XSLTProcessor don't process 'omit-xml-declaration' in 'xsl:output'. If
'omit-xml-declaration' set to 'yes' than xml declaration will be
output; when set to 'no', than xml declaration will be output too.
Reproduce code:
---------------
<?php
$xsl = new DomDocument();
$xsl->loadXML(
'<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl">
<xsl:output method="xml" omit-xml-declaration="no"/>
<xsl:template match="/">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>'
);
$xml = new DomDocument;
$xml->loadXML('<?xml version="1.0"?><null>test</null>');
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl);
$dom = $proc->transformToDoc($xml);
echo $dom->saveXML();
?>
Expected result:
----------------
test
Actual result:
--------------
<?xml version="1.0"?>
test
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29623&edit=1