Hi,
Thank you for the reply, I am sure this will do the job :-).
The v2.0 solution to this problem, could be nice to see. So, If someone
of you could show me, I would appreciate that.
GeirrP
-----Original Message-----
From: Haarman, Michael [mailto:mhaarman(_at_)ibsys(_dot_)com]
Sent: 11. november 2005 20:49
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] Grouping and numbering in XSLT 2.0,
-----Original Message-----
From: geirr.prestholdt
vendor. I have no number to use as grouping key, but as you can
You cannot use position() for the *use* expression of a key, it will
always return 1, but you can use something comparable, such as the count
of preceding-sibling nodes:
<xsl:key name="company" match="*/cell[(_at_)name = 'Company']/value"
use="count(preceding-sibling::value) + 1"/>
<xsl:key name="cage" match="*/cell[(_at_)name = 'Cage']/value"
use="count(preceding-sibling::value) + 1"/>
<xsl:key name="address" match="*/cell[(_at_)name = 'Address']/value"
use="count(preceding-sibling::value) + 1"/>
A main template to get things going:
<xsl:template match="/">
<Vendors>
<xsl:call-template name="getVendors">
<xsl:with-param name="count" select="1"/>
<xsl:with-param name="total"
select="count(*/cell[(_at_)name = 'Company']/value)"/>
</xsl:call-template>
</Vendors>
</xsl:template>
And a named template to call a number of times:
<xsl:template name="getVendors">
<xsl:param name="count" select="1"/>
<xsl:param name="total" select="1"/>
<xsl:choose>
<xsl:when test="$count <= $total">
<vendor>
<cell name="Company">
<value><xsl:value-of select="key('company', $count)"/></value>
</cell>
<cell name="Cage">
<value><xsl:value-of select="key('cage', $count)"/></value>
</cell>
<cell name="Address">
<value><xsl:value-of select="key('address', $count)"/></value>
</cell>
</vendor>
<xsl:call-template name="getVendors">
<xsl:with-param name="count" select="$count + 1"/>
<xsl:with-param name="total" select="$total"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
There is probably a three-line v2.0 solution to this, but I've been out
of the loop lately.
HTH,
Mike
-----------------------------------
Mike Haarman,
XSL Developer,
Internet Broadcasting Systems, Inc.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--