Subject: Re: XSL-T should naturally loop? not grabbing all the children node-sets..
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 22 Apr 2008 17:16:29 +0100
|
perhaps something like
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output encoding="iso-8859-1" method="xml" indent="yes"/>
<xsl:param name="paraCatagory"/>
<xsl:template match="menu">
<xsl:apply-templates select="category[@name=$paraCatagory]"/>
</xsl:template>
<xsl:template match="category">
<div class="cat_block">
<xsl:choose>
<xsl:when test="parent::menu">
<xsl:attribute name="class">cat_block</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">cat_module</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="category/@display_name"/>
<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
<xsl:apply-templates select="category"/>
</div>
</xsl:template>
</xsl:stylesheet>
which makes
$ saxon loop.xml loop.xsl paraCatagory=c2_products
<?xml version="1.0" encoding="iso-8859-1"?>
<div class="cat_block">sub-Category c2_sub1<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
<div class="cat_module">
<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
</div>
<div class="cat_module">
<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
</div>
<div class="cat_module">sub-sub-Category c2_sub_sub1<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
<div class="cat_module">
<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
</div>
<div class="cat_module">
<br/>
<a href="info/link">
<img src="info/images/image"/>
</a>
</div>
</div>
</div>
(I switched xsl:output to use xml indenting, just to make it clearer
what the output is)
David
|