better way?

[email protected] (Kevin Waterson)
Newsgroups php.xml.dev
Organization Oceania
Message-ID <[email protected]>
From an earlier thread I modified this with the 
new function names.. but, what I wish to do is
load an external xsl doc. Is this possible?
something like: $dom->applyXslDoc('my.xsl');


<?php
// create new xsltprocessor
$proc = new xsltprocessor();
// create new domDocument
$dom = new domDocument;
// create new domDocument
$dom2 = new domDocument;
                                                                                                                   
// load domDocument from string
$dom2->loadxml('<?xml version="1.0" encoding="UTF-8"?><root>hello world</root>');
// load domDocument from string
$dom->loadxml('<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="root"/>
<p/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>');
                                                                                                                   
// import stylesheet from domDocument
$proc->importStylesheet($dom);
                                                                                                                   
// create domDocument from transformation (returns domDocument)
$result = $proc->transformToDoc($dom2);
// output domDocument xml to string
print $result->savexml();
?>

Kind regards
Kevin
-- 
 ______                              
(_____ \                             
 _____) )  ____   ____   ____   ____ 
|  ____/  / _  ) / _  | / ___) / _  )
| |      ( (/ / ( ( | |( (___ ( (/ / 
|_|       \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia
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.