note 109379 modified in xsltprocessor.importstylesheet by danbrown
| From: | danbrown@php.net | Date: | Mon, 16 Jul 2012 15:35:23 +0000 |
| Subject: | note 109379 modified in xsltprocessor.importstylesheet by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189188@lists.php.net to get a copy of this message | ||
To make your import dynamic, try this
code: <?php $dom = new
DOMDocument(); $dom->load('main.xsl'); $xpath
= new DomXPath($dom); $importnode=
$questionsXsl->createElement('xsl:include'); $attr=
$questionsXsl->createAttribute('href'); $attr->value
=
'import.xsl'; $importnode->appendChild($attr); $dom->documentElement->insertBefore($importnode,$ref); $dom->loadXml($dom->saveXml()); ?> this
code basically loads the main stylesheet, prepend the import xsl code then reload as xml string so
the imported stylesheet will be loaded at dom.
--was--
To make your import dynamic, try this code:
$dom = new DOMDocument();
$dom->load('main.xsl');
$xpath = new DomXPath($dom);
$importnode= $questionsXsl->createElement('xsl:include');
$attr= $questionsXsl->createAttribute('href');
$attr->value = 'import.xsl';
$importnode->appendChild($attr);
$dom->documentElement->insertBefore($importnode,$ref);
$dom->loadXml($dom->saveXml());
this code basically loads the main stylesheet, prepend the import xsl code then reload as xml string
so the imported stylesheet will be loaded at dom.
http://php.net/manual/en/xsltprocessor.importstylesheet.php