Hi everyone! I'm new to XSLT so please bear with me. I'm trying to generate nested lists based on the XML below. The ParentID field is a reference to the ID field in other "tables." For example ParentID=0 is the root list, ParentIDs of 1 refer to the root list item with an ID of 1. My problem is generating the child lists specifically the call to the template inside of itself (recursive call). What ever I try in the select attribute (<xsl:with-param name="content" select="/"/>) it does not loop back through the document.
Thanks.
Here are my 2 templates in one XSLT file
Code:
<xsl:template match="NewDataSet">
<div id="product_list">[list]
<xsl:call-template name="category">
<xsl:with-param name="content" select="NewDataSet"/>
<xsl:with-param name="ParentID" select="0"/>
</xsl:call-template>
</ul>
</div>
</xsl:template>
<xsl:template name="category">
<xsl:param name="ParentID"/>
<xsl:param name="content"/>
<xsl:for-each select="Table">
<xsl:if test="ParentID=number($ParentID)">
<li>
<a>
<xsl:attribute name="href">/url.aspx?categoryID=<xsl:value-of select="ID" /></xsl:attribute>
<xsl:value-of select="Name" />
</a>
<xsl:call-template name="category">
<xsl:with-param name="content" select="/"/>
<xsl:with-param name="ParentID" select="ID"/>
</xsl:call-template>
</li>
</xsl:if>
</xsl:for-each>
</xsl:template>
Here is my xml document:
Code:
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet>
<Table>
<ID>1</ID>
<Name>Book</Name>
<Description />
<ParentID>0</ParentID>
</Table>
<Table>
<ID>3</ID>
<Name>Food</Name>
<Description />
<ParentID>1</ParentID>
</Table>
<Table>
<ID>6</ID>
<Name>Men's</Name>
<Description />
<ParentID>4</ParentID>
</Table>
<Table>
<ID>10</ID>
<Name>Dresses</Name>
<Description />
<ParentID>9</ParentID>
</Table>
<Table>
<ID>12</ID>
<Name>Jackets</Name>
<Description />
<ParentID>6</ParentID>
</Table>
<Table>
<ID>11</ID>
<Name>Sports Wear</Name>
<Description />
<ParentID>9</ParentID>
</Table>
<Table>
<ID>7</ID>
<Name>Women's</Name>
<Description />
<ParentID>4</ParentID>
</Table>
<Table>
<ID>4</ID>
<Name>Clothes</Name>
<Description />
<ParentID>0</ParentID>
</Table>
<Table>
<ID>2</ID>
<Name>Dating</Name>
<Description />
<ParentID>1</ParentID>
</Table>
<Table>
<ID>5</ID>
<Name>Stuff</Name>
<Description />
<ParentID>0</ParentID>
</Table>
<Table>
<ID>8</ID>
<Name>Boy's</Name>
<Description />
<ParentID>4</ParentID>
</Table>
<Table>
<ID>9</ID>
<Name>Girl's</Name>
<Description />
<ParentID>4</ParentID>
</Table>
</NewDataSet>
Chuck Boyer, MCSD.NET
Dir. of Production and Development
Edge Media, Inc.