note 46207 deleted from function.xsl-xsltprocessor-transform-to-uri by didou
| From: | didou@php.net | Date: | Mon, 27 Dec 2004 22:28:45 +0000 |
| Subject: | note 46207 deleted from function.xsl-xsltprocessor-transform-to-uri by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-82372@lists.php.net to get a copy of this message | ||
Note Submitter: thomasgm at php dot net
----
you have these two simple XML and XSL files:
--simpletree.xml--
<collection>
<cd>
<title>PHP Rock</title>
<artist>Joe Coder</artist>
<year>2003</year>
</cd>
<cd>
<title>Squashing Typos on a Winter's Eve</title>
<artist>kennyt</artist>
<year>2004</year>
</cd>
</collection>
--simpletree.xsl--
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="no"/>
<xsl:template match="collection">
Hey! Welcome to my sweet CD collection!
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="cd">
<h1><xsl:value-of select="title"/></h1>
<h2>by <xsl:value-of select="artist"/></h2>
<h3> - <xsl:value-of select="year"/></h3>
</xsl:template>
</xsl:stylesheet>
Now its time to teach you for what is transformToURI() =)
--simpletree.php--
<?php
/* Load the two XML sources */
$xml = new DomDocument; // from /ext/dom
$xml->load('simpletree.xml');
$xsl = new DomDocument;
$xsl->load('simpletree.xsl');
/* Configure the transformer */
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
/* the function below will write an file contain all infos about the two files above */
$proc->transformToURI($xml, 'file.txt');
?>
--file.txt--
Hey! Welcome to my sweet CD collection!
PHP Rockby Joe Coder - 2003
Squashing Typos on a Winter's Eveby kennyt - 2004