php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: x-penguin at tut dot by
New email:
PHP Version: OS:

 

 [2004-08-12 02:28 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 29 08:01:25 2020 UTC