Raman,
The recursive algorithm works very well for me with XalanJ2.4.1. It is
also
much faster than the variant with generate-id().
I tested it with a record (type="normal"), which has 200 following
siblings
record (type="continuation").
With this source xml the recursive transformationtakes 781 ms to run. The
transformation with generate-id() takes 18687 ms.
FYI, the transformation that uses keys is only slightly slower than the
recursive transformation. With the same source xml it takes 1151ms.
This means that the results of my experiments significantly contradict your
findings. Maybe you didn't use exactly the same transformation or are using
an older version of Xalan?
Here's the transformation, which uses keys:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="kCont" match="record[(_at_)type='continuation']"
use="generate-id(preceding-sibling::record
[(_at_)type = 'normal'][1]
)"/>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="records">
<records>
<xsl:apply-templates select="record[(_at_)type = 'normal']" />
</records>
</xsl:template>
<xsl:template match="record">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
<xsl:apply-templates
select="key('kCont', generate-id())"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list