<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Example collection.xml and collection.xsl files</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="xsl.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.xsltprocessor.html">XSLTProcessor</a></div> <div class="up"><a href="xsl.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="xsl.examples-collection" class="section"> <h2 class="title">Example collection.xml and collection.xsl files</h2> <p class="para"> Many examples in this reference require both an XML and an XSL file. We will use <var class="filename">collection.xml</var> and <var class="filename">collection.xsl</var> that contains the following: </p> <p class="para"> <div class="example" id="example-5536"> <p><strong>Example #1 collection.xml</strong></p> <div class="example-contents"> <div class="xmlcode"><pre class="xmlcode"><collection> <cd> <title>Fight for your mind</title> <artist>Ben Harper</artist> <year>1995</year> </cd> <cd> <title>Electric Ladyland</title> <artist>Jimi Hendrix</artist> <year>1997</year> </cd> </collection></pre> </div> </div> </div> <div class="example" id="example-5537"> <p><strong>Example #2 collection.xsl</strong></p> <div class="example-contents"> <div class="xmlcode"><pre class="xmlcode"><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="owner" select="'Nicolas Eliaszewicz'"/> <xsl:output method="html" encoding="iso-8859-1" indent="no"/> <xsl:template match="collection"> Hey! Welcome to <xsl:value-of select="$owner"/>'s 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"/> - <xsl:value-of select="year"/></h2> <hr /> </xsl:template> </xsl:stylesheet></pre> </div> </div> </div> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="xsl.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.xsltprocessor.html">XSLTProcessor</a></div> <div class="up"><a href="xsl.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>