I am struggling with what is turning out to be a rather nasty problem using
FOP 0.20.5 . I have a set of unordered nodes along the lines of :...
<ITEM item_id='1'> <CARD number='123456789' \> <AMOUNT amt='100'\>
</ITEM>
<ITEM item_id='2'> <CARD number='987654321' \> <AMOUNT amt='30'\>
</ITEM>
<ITEM item_id='3'> <CARD number='123456789' \> <AMOUNT amt='200'\>
</ITEM>
<ITEM item_id='4'> <CARD number='123456789' \> <AMOUNT amt='50'\>
</ITEM>
The <ITEM> nodes can be in any order. What I would like to get at the end
is the following out put.
Card: 123456789 Total:350
Card: 987654321 Total: 30
At the moment I can't even sort unique! I have tried to sort the nodes and
then compare the current node to the following sibling, using...
<xsl:for-each select=".//ITEM" >
<xsl:sort select="CARD/@number" order="ascending" />
<xsl:if test="./CARD/@number[ not
(.=following-sibling::ITEM/CARD/@number) ]">
....print number etc. etc....
But what I have found is that the following sibling is as it would be if
the nodes have not been ordered. I have proven this to myself using
something along the lines of...
<xsl:for-each select=".//ITEM" >
<xsl:sort select="CARD/@number" order="ascending" />
<fo:block>
CUR NUMBER: <xsl:value-of select=".//CARD/@number"/>
NXT NUMBER: <xsl:value-of select="following-sibling::
*/CARD/@number"/>
CUR ID IS: <xsl:value-of select="./@item_id"/>
NXT ID IS: <xsl:value-of select="following-sibling::
*/@item_id"/>
</fo:block>
</xsl:for-each>
I fear that the only way to deal with this is to use XSLT to preorder the
nodes and then use a 2nd script using the same approach as described.
Alternatively I could go right back to the process that originally created
the XML file and order / sub total from there... something I really want to
avoid if at all possible.
Is there another approach I can take ? Am I expecting too much from XSLT
with all this... ?
Thanks for any help in advance...
Roger.
***************************************
Roger Wyatt
Principal Consultant
Nomad Software Ltd.
***************************************
This e-mail (including attachments) is confidential and is intended solely
for the addressee. Unless authorised you may not read, copy, use or store
this e-mail in any way, or permit others to do so. If you have received it
in error, please contact Nomad Software on +44 (0) 20 7292 2400