[Home] [By Thread] [By Date] [Recent Entries]
Michael Kay wrote:
That works great thanks! Except generalCase.xsl should not have the import. I renamed mine to layout.xsl (aka generalCase.xsl) and list.xsl (aka specialCase.xsl). I now need to find out why it works, ie. what mode is :) [layout.xsl] <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <html> <head> <title>Something</title> </head> <body> <xsl:apply-templates select="." mode="view"/> </body> </html> </xsl:template> </xsl:stylesheet> [list.xsl] <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="layout.xsl"/> <xsl:template match="/" mode="view"> <h1>List of People</h1> <xsl:for-each select="/data/people/person"> <div id="person" style="margin-bottom: 10px;"> <xsl:value-of select="@id"/> <BR/> <xsl:value-of select="firstname"/> <BR/> <xsl:value-of select="lastname"/> <BR/> </div> </xsl:for-each> </xsl:template> </xsl:stylesheet> [data.xml] <?xml version="1.0" encoding="UTF-8"?>
<data>
<title>List of people</title>
<people>
<person id="1">
<firstname>Harry</firstname>
<lastname>Love</lastname>
</person>
<person id="2">
<firstname>Tim</firstname>
<lastname>Burton</lastname>
</person>
</people>
</data>Michael Kay http://www.saxonica.com/
|

Cart



