Dear all,
I need to group unique nodes based on the finestclasses using a recursive template. Calculation is involved- I also need to use xsl:param and xsl:key to group the unique nodes. It's not as easy as it sounds..
I need to put the books onto "shelves" so that no finestclass is split across two "shelves" and all finestclasses are assigned to "shelves".
The scenario:
There are 3 bookcases: each bookcase have 6 shelves or rows:
one small shelf (occupies the top shelf)
three medium shelves (occupies the next three shelves)
two large shelves (occupies the last two bottom shelves)
Only small books can go on the top shelves. Small or Medium size books can go on the Medium shelves and any books can go on the two large shelves at the bottom of each bookcase.
large books - 40 units
medium books - 24 units
small books - 15 units
*in total, there are 600 "units" -also known as the size of a shelf
please refer to the <unit> node below
here's the sample xml:
<mybooks>
<book>
<author> Brian</author>
<title>Cracking</title>
<type>Large</type>
<finestclasses>Animation</
finestclas
ses>
<unit>40</unit> //occupies 40 units out of the 600 units in one shelf
</book>
- <book>
<author>Chuck</author>
<title>Chuck Amuck</title>
<type>Large</type>
<finestclasses>Animation</
finestclas
ses>
<unit>40</unit>
</book>
<book>
<author>Cors</author>
<title>Cracking</title>
<type>Large</type>
<finestclasses>Biography</
finestclas
ses>
<unit>40</unit>
</book>
- <book>
<author>Bell</author>
<title>Roosevelt</title>
<type>Medium</type>
<finestclasses>Biography</
finestclas
ses>
<unit>24</unit>
</book>
<mybooks>
the output should be like this:
<mybooks>
<book>
<finestclass>Animation</fi
nestclass>
<bookcase>1</bookcase>
<shelf>5</shelf>
<totalunit>80</totalunit> //this is the total of the units of the Animation finestclass
<type>Large</type>
</book>
<book>
<finestclass>Biography</fi
nestclass>
<bookcase>1</bookcase>
<shelf>5</shelf>
<totalunit>64</totalunit>
<type>Large</type> //this is the largest type of book under the Biography finestclass
</book>
</mybooks>
The full xml file can be downloaded at:
www.winarm.com/sunshine/mybooks.xmlThank you in advance!
sunshine