I'm having a bit of trouble coming up with the =
XPath/XSLT=20
expression to express an algorithm.

<!--This is an example XML Fragment that my =
algorithm needs=20
to work on-->

<parent-node = type=3D"generated">

=20 <child-node id=3D"first-child"=20 number-of-pages=3D"10">

<![CDATA[Text of page would go=20 here]]>

= </child-node>

=20 <child-node id=3D"second-child"=20 number-of-pages=3D"5">

<![CDATA[Text of page would go=20 here]]>

= </child-node>

=20 <child-node id=3D"third-child"=20 number-of-pages=3D"20">

<![CDATA[Text of page goes=20 here]]>

=20 </child-node>

</parent-node>

<parent-node = type=3D"generated">

=20 <child-node id=3D"first-child"=20 number-of-pages=3D"10">

<![CDATA[Text of page would go=20 here]]>

= </child-node>

=20 <child-node id=3D"second-child"=20 number-of-pages=3D"5">

<![CDATA[Text of page would go=20 here]]>

= </child-node>

=20 <child-node id=3D"third-child"=20 number-of-pages=3D"20">

<![CDATA[Text of page goes=20 here]]>

=20 </child-node>

</parent-node>

<!--This is the output fragment that my algorithm =
should=20
yield-->

=20 Table of Contents

first=20 child.................................1

second=20 child................................11

third=20 child.................................16

=20 Table of Contents

first=20 child.................................1

second=20 child................................11

third=20 child.................................16

*The "...." are not really part of the output. =
They are=20
simply for formatting and clarity

The purpose of the algorithm is to find out what =
page the=20
'CDATA' section of each 'child-node' would start on,

assuming that = each CDATA=20 section would begin on a new page. This can be expressed as the = following=20 algorithm (in psuedo code):

- When the current 'child-node' is being=20 processed

- For every 'child-node' before the current 'child-node' = get the=20 value of the 'number-of-pages' attribute

- Sum the values then add = 1

- The=20 value of the previous step is the page number that the 'CDATA' section = of the=20 current 'child-node' will start on ...

assuming that = each CDATA=20 section would begin on a new page. This can be expressed as the = following=20 algorithm (in psuedo code):

- When the current 'child-node' is being=20 processed

- For every 'child-node' before the current 'child-node' = get the=20 value of the 'number-of-pages' attribute

- Sum the values then add = 1

- The=20 value of the previous step is the page number that the 'CDATA' section = of the=20 current 'child-node' will start on ...

... Therefore if there were a forth-child element it =
would=20
print,

fourth child............................. 36 (because 20 + 5 + = 10 + 1=20 =3D 36)

fourth child............................. 36 (because 20 + 5 + = 10 + 1=20 =3D 36)

The XSLT/XPath construct that I currently have looks like this = (pretend=20 the spacing, carriage returns, and tabs are being magically handled): =

<xsl:template=20
match=3D"parent-node[@type=3D'generated']">

Table of=20 Contents

Table of=20 Contents

<xsl:for-each =
select=3D"child-node">

<xsl:value-of=20 select=3D"@id"/>..............<xsl:number=20 value=3D"sum(previous-siblings[attribute::pageCount)"/><!-- point = of=20 interest = (POC)-->

</xsl:for-each>

</xsl:template>

<xsl:value-of=20 select=3D"@id"/>..............<xsl:number=20 value=3D"sum(previous-siblings[attribute::pageCount)"/><!-- point = of=20 interest = (POC)-->

</xsl:for-each>

</xsl:template>

I've tried all sorts of different expressions at POC. The = one you=20 see now is just the latest. Any help would be greatly=20 appreciated.