Bug->Doc #66937 [Asn->Opn]: XSLTProcessor::transformToDoc causes separation of doctype and source document
| From: | cmb@php.net | Date: | Tue, 14 Jul 2020 11:58:42 +0000 |
| Subject: | Bug->Doc #66937 [Asn->Opn]: XSLTProcessor::transformToDoc causes separation of doctype and source document | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17706@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: Assigned
+Status: Open
-Type: Bug
+Type: Documentation Problem
Package: XSLT related
Operating System: OS X
PHP Version: 5.5.10
-Assigned To: cmb
+Assigned To:
Block user comment: N
Private report: N
New Comment:
I have serious doubts that we should fix this (without also fixing
other potential modifications to the source document), so I'm
reclassifying as documentation issue.
Previous Comments:
------------------------------------------------------------------------
[2020-06-12 14:14:23] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #66937: transformToDoc() removes DTD of source document
On GitHub: https://github.com/php/php-src/pull/5704
Patch: https://github.com/php/php-src/pull/5704.patch
------------------------------------------------------------------------
[2020-06-12 14:11:36] cmb@php.net
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>
------------------------------------------------------------------------
[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