Ok I am trying to build a table, But I'm not doing this correctly, I have no XSL example as nothing I tried came close to what I need. (I have tried using xsl:apply-templates loops, even with modes, and even xsl:for-each and key() but cannot get the right filters.
Here is an example of the XML I would be using. (the real xml I am using is more complex then this one below)
<report>
<item>
<vertical>
<component>
<partname>Left Side</partname>
<parttype>Side</parttype>
<partlocation>Outside</partlocation>
<material>Wood</material>
<thickness>20mm</thickness>
<colour>White</colour>
</component>
</vertical>
<vertical>
<component>
<partname>Right Side</partname>
<parttype>Side</parttype>
<partlocation>Outside</partlocation>
<material>Wood</material>
<thickness>20mm</thickness>
<colour>White</colour>
</component>
</vertical>
<vertical>
<component>
<partname>Back</partname>
<parttype>Back</parttype>
<partlocation>Inside</partlocation>
<material>Plastic</material>
<thickness>3mm</thickness>
<colour>Black</colour>
</component>
</vertical>
</item>
</report>
So the task I am wanting to do is, for-each <item>
I need to start making a table, and inside that table I need to assess each <component>
to find how many have the same <material>
, <thickness>
and <colour>
.
Then I need to list the Material name and details.
Next I need all the <components>
that have the same <parttypes>
and <partlocation>
that are of the same <material>
, <thickness>
and <colour>
, to show their <partname>
in a row for each one.
There is no fixed amount of materials I can expect, one time I might get 1, another time I could get 3. And I wont always know what values the nodes will contain.
Also in each <item>
I can have 1-3 different <parttype>
and <partlocation>
(althought they work in pairs - and I know what the values of those nodes will be)
Here is a sample of the formatted finish given the really simple above code...
Wood, 20mm, White
Left Side
Right Side
Plastic, 3mm, Black
Back
this question is VERY similar, but not quite... xsl grouping of repetitive nodes by xml element in xslt1