php.net |  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
Votes:1
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
 [2014-03-20 17:55 UTC] 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/>

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-12 14:11 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-06-12 14:11 UTC] 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>
 [2020-06-12 14:14 UTC] 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-07-14 11:58 UTC] cmb@php.net
-Status: Assigned +Status: Open -Type: Bug +Type: Documentation Problem -Assigned To: cmb +Assigned To:
 [2020-07-14 11:58 UTC] cmb@php.net
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: Thu Nov 21 13:01:29 2024 UTC