php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50989 LIBXML_NOXMLDECL and xsl:output omit-xml-declaration
Submitted: 2010-02-10 07:50 UTC Modified: 2016-04-30 03:59 UTC
Votes:47
Avg. Score:4.3 ± 0.9
Reproduced:39 of 39 (100.0%)
Same Version:13 (33.3%)
Same OS:12 (30.8%)
From: zachatwork at gmail dot com Assigned: jhdxr (profile)
Status: Closed Package: DOM XML related
PHP Version: * OS: Debian Linux 5.0.3
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: zachatwork at gmail dot com
New email:
PHP Version: OS:

 

 [2010-02-10 07:50 UTC] zachatwork at gmail dot com
Description:
------------
libxml defines a constant LIBXML_NOXMLDECL, however DOMDocument doesn't currently honor this variable. It is an extremely useful/important feature because XHTML with an XML declaration triggers "quirks" mode in IE6. 

Similarly, XSLTProcessor does not honor the "omit-xml-declaration" attribute of the <xsl:output> element. 

It would be very useful if support for one or both of these items were added. 


Reproduce code:
---------------
---
From manual page: libxml.constants
---

<?php

print "PHP_VERSION:      ".PHP_VERSION."\n";
print "LIBXML_VERSION:   ".LIBXML_VERSION."\n";
print "LIBXML_NOXMLDECL: ".LIBXML_NOXMLDECL."\n";

$dom = new DomDocument();
$dom->loadXML("<foo />");

# This should work but doesn't.

print "DOMDocument doesn't honor LIBXML_NOXMLDECL:\n";
print $dom->saveXML(null,LIBXML_NOXMLDECL);

# This works, and will still work after the above is fixed.

print "Forwards compatible workaround:\n";
$lines = explode("\n", $dom->saveXML(null, LIBXML_NOXMLDECL), 2);
if(!preg_match('/^\<\?xml/', $lines[0]))
    print $lines[0];
print $lines[1];

?>


Expected result:
----------------
PHP_VERSION:      5.3.0
LIBXML_VERSION:   20703
LIBXML_NOXMLDECL: 2
DOMDocument doesn't honor LIBXML_NOXMLDECL:
<foo/>
Forwards compatible workaround:
<foo/>


Actual result:
--------------
PHP_VERSION:      5.3.0
LIBXML_VERSION:   20703
LIBXML_NOXMLDECL: 2
DOMDocument doesn't honor LIBXML_NOXMLDECL:
<?xml version="1.0"?>
<foo/>
Forwards compatible workaround:
<foo/>


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 10:09 UTC] jani@php.net
-Package: Feature/Change Request +Package: DOM XML related
 [2016-04-30 03:59 UTC] jhdxr@php.net
-PHP Version: 5.3.1 +PHP Version: * -Assigned To: +Assigned To: jhdxr
 [2016-04-30 03:59 UTC] jhdxr@php.net
The original implement use `xmlDocDumpFormatMemory` which does not support `XML_SAVE_NO_DECL`, I replaced them with xmlsave api so it will be supported after merged.
 [2017-01-28 08:28 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2fcf1259c6a9c1d70bcdfb96aeabc54c47e2a4a0
Log: fixed bug #50989 (DOM support for LIBXML_NOXMLDECL)
 [2017-01-28 08:28 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 [2017-02-01 19:07 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3446e3b7496549ff8bfee31271744a6ec4fda03a
Log: Revert &quot;fixed bug #50989 (DOM support for LIBXML_NOXMLDECL)&quot;
 [2017-02-01 19:18 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5c34a30bdbc8924f441c8def5abece46d3dbfe8a
Log: Revert &quot;fixed bug #50989 (DOM support for LIBXML_NOXMLDECL)&quot;
 [2017-02-01 19:24 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=68683a4338d74be3f8fb111d953ab51082b04357
Log: Revert &quot;fixed bug #50989 (DOM support for LIBXML_NOXMLDECL)&quot;
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Feb 16 14:01:31 2025 UTC