I have an xml output like this:
<data>
<item-types>
<entry id="1" items="5">
<category>Frozen</category>
</entry>
<entry id="2" items="4">
<category>Breakfast</category>
</entry>
</item-types>
<items>
<entry id="28">
<item-number>1115</item-number>
<name>Marion Berries, IQF</name>
<area>
<item id="1">Groceries - Frozen</item>
</area>
</entry>
<entry id="29">
<item-number>1117</item-number>
<name>Peach Cups</name>
<area>
<item id="1">Groceries - Frozen</item>
</area>
</entry>
<entry id="35">
<item-number>1570</item-number>
<name>Sausage Patty</name>
<area>
<item id="2">Groceries - Breakfast</item>
</area>
</entry>
<entry id="32">
<item-number>1575</item-number>
<name>French Toast Stix, WG</name>
<area>
<item id="2">Groceries - Breakfast</item>
</area>
</entry>
</items>
</data>
The items-types
are the categories of the items below. item-types/entry/@id
relates directly to items/entry/area/item/@id
and I'm trying to organize the items in to the categories for my output.
So far I am using the following XSL transformation.
<xsl:template match="item-types/entry">
<h3><xsl:value-of select="concat(@id,'. ',category)" /></h3>
<ul>
<xsl:apply-templates select="/data/items/entry[area/item/@id = @id]" />
</ul>
</xsl:template>
<xsl:template match="items/entry">
<li>
<xsl:value-of select="concat(item-number,'. ',name,' (',area/item/@id,')')" />
</li>
</xsl:template>
The problem is it's not working. I believe the problem is the predicate on line 4 of the transformation: [area/item/@id = @id]
When I remove this, it shows all the items in every category.
Is there a way to show the "Frozen" items in the "Frozen" category and the "Breakfast" items in the "Breakfast" category?
Thanks!