|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66937 XSLTProcessor::transformToDoc causes separation of doctype and source document
Submitted: 2014-03-20 17:55 UTC Modified: 2020-07-14 11:58 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: sites at hubmed dot org Assigned:
Status: Open Package: XSLT related
PHP Version: 5.5.10 OS: OS X
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-03-20 17:55 UTC] sites at hubmed dot org
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:

<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//example//EN" "">

Expected result:
<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//example//EN" "">

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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-12 14:11 UTC]
-Assigned To: +Assigned To: cmb
 [2020-06-12 14:11 UTC]
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] <>
 [2020-06-12 14:14 UTC]
The following pull request has been associated:

Patch Name: Fix #66937: transformToDoc() removes DTD of source document
On GitHub:
 [2020-07-14 11:58 UTC]
-Status: Assigned +Status: Open -Type: Bug +Type: Documentation Problem -Assigned To: cmb +Assigned To:
 [2020-07-14 11:58 UTC]
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 09:01:28 2024 UTC