Do chaining methods with PHP is easy . But I need something like this,
$xml = $dom->transformToThis('file1.xsl')->transformToThis('file2.xsl')->saveXML();
or
$books = $dom-> transformToThis('file1.xsl')-> transformToThis('file2.xsl')-> getElementsByTagName('book');
Is this possible with PHP DOMDocument or DOMNode ?
class DOMxx extends DOMDocument { public function __construct() { parent::__construct("1.0", "UTF-8"); } function trasformToThis($xslfile) { $xsldom = new DOMDocument('1.0', 'UTF-8'); $xsldom->load($xslfile); $xproc = new XSLTProcessor(); $xproc->importStylesheet($xsldom); $this = $xproc->transformToDoc($this);
$this = X is an invalid construct in PHP, and I don't understand the workaround described here . I can use something like $this->loadXML( $xproc->transformToDoc($this)->saveXML() ); but this is a big overload, and the question is how to do the right thing.
Another (wrong) way to try to implement,
function trasformToThis($xslfile) { ... same ... return $xproc->transformToDoc($this);
therefore, in this case, the question arises: "How to transfer to DOMxx?".
Peter Krauss
source share