RE: [xsl] XSL-T should naturally loop? not grabbing all the children node-sets..

Subject: RE: [xsl] XSL-T should naturally loop? not grabbing all the children node-sets..
From: "Dan Acuff" <dacuff@xxxxxxxxxxxxxx>
Date: Tue, 22 Apr 2008 12:36:14 -0400
Here is the way each child-node-set should be formatted.

<div class="cat_block">
<div class="cat_module">
sub-Category c2_sub1
<br/>
<a href="/products/c2_products/c2_sub1_products">
<img src="/imagesEdp/default_sm.jpg"/>
</a>
</div>
</div>

trouble is it stops there when it should also create html code for:

<div class="cat_block">
<div class="cat_module">
sub-Category c2_sub2
<br/>
<a href="/products/c2_products/c2_sub2_products">
<img src="/imagesEdp/default_sm.jpg"/>
</a>
</div>
</div>

and:

<div class="cat_block">
<div class="cat_module">
sub-Category c2_sub3
<br/>
<a href="/category/c2_products/c2_sub3_products"> <!-- category becuase
this one ALSO has sub-node-sets..
<img src="/imagesEdp/default_sm.jpg"/>
</a>
</div>
</div>

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Tuesday, April 22, 2008 12:16 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSL-T should naturally loop? not grabbing all the
children node-sets..



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

Current Thread