Re: multiple xsl docs
| From: | Kevin Waterson | Date: | Wed, 13 Aug 2003 22:24:38 +0000 |
| Subject: | Re: multiple xsl docs | ||
| References: | 1 | Groups: | php.xml.dev |
| Request: | Send a blank email to php-xml-dev+get-186@lists.php.net to get a copy of this message | ||
This one time, at band camp, Christian Stocker <chregu@bitflux.ch> wrote:
> there's no sense in adding a second one IMHO, just transform your XML
> with the first one and then with the second one
perhaps an example would help, this is what I am doing..
// create new xsltprocessor
$proc = new xsltprocessor();
// create a second xsltprocessor
$proc2 = new xsltprocessor();
// create new domDocument, this will be the XML
$dom = new domDocument;
// create new domDocument, the main xsl stylesheet
$dom2 = new domDocument;
// dom3 is the second xsl stylesheet
$dom3 = new domDocument;
// load the xmlstring
$dom->loadxml($xmlstring);
// load domDocument from string, the xsl document is also the theme
// and is stored in the themes directory
$dom2->load('./path/to/first.xsl');
// load the xsl from the extention
$dom3->load('./path/to/second.xsl');
// import stylesheet from domDocument
$proc->importStylesheet($dom2);
// process the xsl from the extension
$proc2->importStylesheet($dom3);
// create domDocument from transformation (returns domDocument)
$result = $proc->transformToDoc($dom);
// transform again with the second xsl doc
$result = $proc2->transformToDoc($dom);
// change the document encoding to HTML
// this is required so we dont get bizarre UTF-8 chars popping up
// when using html entities such as  
$result->encoding = "HTML";
// output domDocument xml to string
print $result->savexml();
Here I create the second dom object and use transformToDoc() to apply
the first, then the second
Kind regards
Kevin
--
______
(_____ \
_____) ) ____ ____ ____ ____
| ____/ / _ ) / _ | / ___) / _ )
| | ( (/ / ( ( | |( (___ ( (/ /
|_| \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia