Edit report at https://bugs.php.net/bug.php?id=53693&edit=1
ID: 53693
Updated by: [email protected]
Reported by: mat at homedvd dot ca
-Summary: transformToDoc, different class
+Summary: ::transformToDoc() $returnClass param docs
insufficient
-Status: Open
+Status: Verified
-Type: Feature/Change Request
+Type: Documentation Problem
Package: XSLT related
Operating System: Any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This is possible for a long time (at least as of PHP 5.3) by using
the almost undocumented 2nd parameter of ::transformToDoc() which
expects the name of the class to return. In your case:
echo $processor->transformToDoc( $sourceDOM, DOMDocumentYouCanFancyPrint::class );
Previous Comments:
------------------------------------------------------------------------
[2011-01-08 05:31:04] mat at homedvd dot ca
Description:
------------
It would be very helpful to allow transformToDoc to return a custom class instance, which would have to extend DOMDocument of course.
The example code provided is simplified. Far better usage could be made from the child DOMDocument class -- this is only an example to illustrate the potential.
Test script:
---------------
class DOMDocumentYouCanFancyPrint extends DOMDocument {
public function __toString() {
return "<pre>" . htmlentities( $this->saveXML() ) . "</pre>";
}
}
...
$processor->registerDocumentClass( "DOMDocumentYouCanFancyPrint" );
echo $processor->transformToDoc( $sourceDOM );
Expected result:
----------------
The expected result would be that the transformToDoc method call returns an instance of DOMDocumentYouCanFancyPrint.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53693&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.