TomWestcott
Programmer
I am trying to print a list of categorys with sub caegorys is they exsist like this
Category
--subcategory1
Category2
This the xml file and xsl file
<table>
<category>
<title>Category1</title>
<parentID>0</parentID>
<categoryID>1</categoryID>
</category>
<category>
<title>Category2</title>
<parentID>0</parentID>
<categoryID>2</categoryID>
</category>
<category>
<title>SubCategory1</title>
<parentID>1</parentID>
<categoryID>3</categoryID>
</category>
</table>
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
utput method='xhtml'
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system = "/>
<xsl:template match="/">
<table class="catMenu">
<thead>
<tr>
<!-- set up the column headings -->
<th>Category</th>
</tr>
</thead>
<tbody>
<!-- add a table row for each non-empty inner record in the XML file -->
<xsl:apply-templates select="//category[count(*)>0]" />
</tbody>
</table>
</xsl:template>
<xsl:template match="category">
<xsl:if test="parentID < 1">
<tr>
<td><a><xsl:attribute name="href">browse.php?catID=<xsl:value-of select="categoryID"/></xsl:attribute><xsl:value-of select="title"/></a></td>
</tr>
<xsl:for-each select="category/parentID" = "1">
<tr>
<td>--<xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
As you can see I need help at the for each bit im a newb!
Thank Tom
Category
--subcategory1
Category2
This the xml file and xsl file
<table>
<category>
<title>Category1</title>
<parentID>0</parentID>
<categoryID>1</categoryID>
</category>
<category>
<title>Category2</title>
<parentID>0</parentID>
<categoryID>2</categoryID>
</category>
<category>
<title>SubCategory1</title>
<parentID>1</parentID>
<categoryID>3</categoryID>
</category>
</table>
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl=" version="1.0">
<xsl
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system = "/>
<xsl:template match="/">
<table class="catMenu">
<thead>
<tr>
<!-- set up the column headings -->
<th>Category</th>
</tr>
</thead>
<tbody>
<!-- add a table row for each non-empty inner record in the XML file -->
<xsl:apply-templates select="//category[count(*)>0]" />
</tbody>
</table>
</xsl:template>
<xsl:template match="category">
<xsl:if test="parentID < 1">
<tr>
<td><a><xsl:attribute name="href">browse.php?catID=<xsl:value-of select="categoryID"/></xsl:attribute><xsl:value-of select="title"/></a></td>
</tr>
<xsl:for-each select="category/parentID" = "1">
<tr>
<td>--<xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
As you can see I need help at the for each bit im a newb!
Thank Tom