xsl-list
[Top] [All Lists]

Count problem

2004-09-17 02:43:41
Hi there,

I need to count nodes to number a ordered list in fo.
I now got an easy structure where a toc of all linked books is built up
from.
The trick is that there is one structure file for all books i got, but
there result 3 different TOCs from, depending on the product_class
attribute of the single books.

Here is the actual structure:

Structure.xml
----------------
(...)
<volume>
<title>title of the volume</title>
<book fileref="book 1 (of class A)" />
<book fileref="book 2 (of class B)" />
<book fileref="book 3 (of class C)" />
<book fileref="book 4 (of class A)" />
</volume>

Linking to books like this:

Book1.xml
----------
<book product_class="A">
(...)

Book2.xml
----------
<book product_class="B">
(...)

The xslt:
----------

The script is runned three times, one run for each product class.
What it does is counting all books in a volume that have the actual
product_class. 

<xsl:number count="book[document(@fileref)/book/@product_class =
$product_class]" />

The output looks like (eg for class A):
----------------------
Volume 1 title of the volume

1. title of book 1
2. title of book 4


This works so far, but now i have to change the structure to something
like this

NEWStructure.xml
----------------
(...)
<volume>
<title>title of the volume</title>
<book fileref="book 1 (of class A)" />
<book fileref="book 2 (of class C)" />
<book fileref="book 3 (of class B)" />
<subvolume>
        <title>title of the subvolume</title>
        <book fileref="book 4 (of class A)" />
        <book fileref="book 5 (of class B)" />
</subvolume>
<book fileref="book 6 (of class C)" />
<book fileref="book 7 (of class A)" />
<book fileref="book 8 (of class B)" />
</volume>


The new output should look like (for Class A):
----------------------
Volume 1 title of the volume

1. title of book 1
2. title of the subvolume
   title of book 4
4. title of book 7 

(for Class C):
----------------------
Volume 1 title of the volume

1. title of book 2
2. title of book 6 

(notice that the subvolume doesnt appear here cause it does not contain
any book of class C)


...nice. I really got no idea how to manage this.


Thx a lot in advance,
sebastian





<Prev in Thread] Current Thread [Next in Thread>