Re: XSL in PHP5

From: Date: Tue, 01 Jul 2003 15:35:50 +0000
Subject: Re: XSL in PHP5
References: 1  Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-148@lists.php.net to get a copy of this message
Example is a little longer as it also includes some of the DOM functionality Honza Skypala wrote in message > I downloaded PHP 5 beta and I see there is a completely new way of XSL > support. "xslt" extension is gone, instead we have "xsl" extension. I > enabled the extension in php.ini file, but - I down know how to work with > it. Can anybody please give me an example, 10 lines of code, that use the > new extension? Please... <?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->import_stylesheet($dom); // following are 3 ways to output the transformation // write transformation output to a file (returns # bytes written) print "Wrote: ".$proc->transform_to_uri($dom2, 'mystylesheet.txt')."\n\n"; // transformation output to a string (returns string) print $proc->transform_to_xml($dom2)."\n\n"; // create domDocument from transformation (returns domDocument) $result = $proc->transform_to_doc($dom2); // output domDocument xml to string print $result->savexml(); ?>

« previous php.xml.dev (#148) next »