php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66937 XSLTProcessor::transformToDoc causes separation of doctype and source document
Submitted: 2014-03-20 17:55 UTC Modified: -
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 15:01:28 2019 UTC