I'm at a total loss here, I need to create an XSL template for an XML file I have, and can't seem to figure out how to get it finished. I would appreciate any help someone can provide.
I have an xml document and the it's made up like this:
- <Catalogue>
-
<ProdID>1</ProdID>
-
<ProdDescription>Bristol Fixture HP Sodium</ProdDescription>
-
<ProdPartNo>AP-0207</ProdPartNo>
-
<ProdTypeID>3</ProdTypeID>
-
<ProdTypeDescription>Ornamental</ProdTypeDescription>
-
<ProdCatID>2</ProdCatID>
-
<ProdCatDescription>Lighting Fixtures</ProdCatDescription>
-
<ProdSubCatID>4</ProdSubCatID>
-
<ProdSubCatDescription>Bristol Series Fixtures</ProdSubCatDescription>
-
<PDFFileName>O2-Renaissance Fixture.pdf</PDFFileName>
-
</Catalogue>
-
I need it to write out a header for each distinct ProdCatID and then under that, a header for each ProdSubCatID with the appropriate ProdPartNo listed under the sub categories.
I have gotten it to the point where I can get the first categories to list with each entry under them, but can't get the second to work.
Here's the code I have so far:
- <xsl:template match="/">
-
<!-- consider all ProdCatDescription, one by one, sorted, no double -->
-
<xsl:for-each select="/NewDataSet/Catalogue/ProdCatDescription[not(../preceding-sibling::Catalogue/ProdCatDescription = .)]">
-
<xsl:sort/>
-
<xsl:call-template name="handle-ProdCatDescription">
-
<xsl:with-param name="ProdCatDescription" select="."/>
-
</xsl:call-template>
-
</xsl:for-each>
-
</xsl:template>
-
-
<!-- display all ProdCatDescription for a give Catalogue -->
-
<xsl:template name="handle-ProdCatDescription">
-
<xsl:param name="ProdCatDescription"/>
-
<xsl:variable name="Catalogues" select="/NewDataSet/Catalogue[ProdCatDescription = $ProdCatDescription]"/>
-
<H3>
-
<xsl:value-of select="$ProdCatDescription"/>, contains <xsl:value-of select="count($Catalogues)"/> Products.
-
</H3>
-
<xsl:for-each select="$Catalogues">
-
<xsl:sort select="ProdSubCatDescription"/>
-
<xsl:sort select="ProdPartNo"/>
-
-
<xsl:value-of select="ProdSubCatDescription"/> :: <xsl:value-of select="ProdPartNo"/>
-
<br/>
-
</xsl:for-each>
-
</xsl:template>
-
This results in:
- Main Category Name 1
-
Sub Category Name 1 :: Product Part Number
-
Sub Category Name 1 :: Product Part Number
-
Sub Category Name 2 :: Product Part Number
-
-
Main Category Name 2...etc...
I need it to look like this, if the Sub Category Names are the same...
- Main Category Name 1
-
Sub Category Name 1
-
Product Part Number
-
Product Part Number
-
Sub Category Name 2
-
Product Part Number
-
-
Main Category Name 2...etc...
I need this done and am at a complete end, any help is much appreciated. Thanks a ton.