Bug #66937 [PATCH]: XSLTProcessor::transformToDoc causes separation of doctype and source document

From: Date: Fri, 12 Jun 2020 14:14:23 +0000
Subject: Bug #66937 [PATCH]: XSLTProcessor::transformToDoc causes separation of doctype and source document
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227451@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 Patch added by: cmb@php.net Reported by: sites at hubmed dot org Summary: XSLTProcessor::transformToDoc causes separation of doctype and source document Status: Assigned Type: Bug Package: XSLT related Operating System: OS X PHP Version: 5.5.10 Assigned To: cmb Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#227451) next »