Bug #66937 [Opn]: XSLTProcessor::transformToDoc causes separation of doctype and source document
| From: | cmb@php.net | Date: | Fri, 12 Jun 2020 14:11:36 +0000 |
| Subject: | Bug #66937 [Opn]: XSLTProcessor::transformToDoc causes separation of doctype and source document | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227450@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66937&edit=1
ID: 66937
Updated by: cmb@php.net
Reported by: sites at hubmed dot org
Summary: XSLTProcessor::transformToDoc causes separation of
doctype and source document
Status: Open
Type: Bug
Package: XSLT related
Operating System: OS X
PHP Version: 5.5.10
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I can confirm the reported behavior. xsltApplyStylesheetUser()
removes the DTD from the given document, which is surprising to
me, but will probably not change in libxslt[1].
[1] <https://mail.gnome.org/archives/xslt/2020-June/msg00001.html>
Previous Comments:
------------------------------------------------------------------------
[2014-03-20 17:55:27] sites at hubmed dot org
Description:
------------
Calling XSLTProcessor::transformToDoc (which would be expected not to alter the source document) on
a DOMDocument that has a doctype causes the doctype to be somehow "separated" from the
document, so that the doctype is no longer included when writing out the original document.
A workaround is to clone the DOMDocument object before calling transformToDoc on it, but this
shouldn't be necessary.
I notice that the "nextSibling" property of the DOMDocumentType object is lost during the
transformation.
=====
Tested with PHP 5.5.10 and 5.4.24.
libxml2 Version => 2.9.0
libxslt Version => 1.1.28
Test script:
---------------
https://gist.github.com/hubgit/9669288
Input:
<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//example//EN" "http://example.org/dtd">
<article/>
Expected result:
----------------
<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//example//EN" "http://example.org/dtd">
<article/>
Actual result:
--------------
<?xml version="1.0"?>
<article/>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66937&edit=1