|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29623 XSLTProcessor don't process 'omit-xml-declaration' in 'xsl:output'
Submitted: 2004-08-12 02:28 UTC Modified: 2004-08-12 08:25 UTC
From: x-penguin at tut dot by Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5CVS-2004-08-12 (dev) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: x-penguin at tut dot by
New email:
PHP Version: OS:


 [2004-08-12 02:28 UTC] x-penguin at tut dot by
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:
$xsl = new DomDocument();
'<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:php="">
<xsl:output method="xml" omit-xml-declaration="no"/>
<xsl:template match="/">
    <xsl:value-of select="."/>

$xml = new DomDocument;
$xml->loadXML('<?xml version="1.0"?><null>test</null>');

$proc = new XSLTProcessor();

$dom = $proc->transformToDoc($xml);
echo $dom->saveXML();

Expected result:

Actual result:
<?xml version="1.0"?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-12 08:25 UTC]
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.


$string = $proc->transformToXml($xml);
print $string;

to achieve what you want

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 16 16:01:23 2021 UTC