Re: [xsl] XSLT2: Keys vs. xsl:choose to distinguish groups

Subject: Re: [xsl] XSLT2: Keys vs. xsl:choose to distinguish groups
From: Yves Forkl <Y.Forkl@xxxxxx>
Date: Tue, 20 Mar 2007 10:40:03 +0100
Michael Kay wrote:
Why not use apply-templates to despatch based on the first member of the

  <xsl:apply-templates select="current-group()[1]" mode="process-group"/>

<xsl:template match="A" mode="process-group">
  <xsl:for-each select="current-group()">

Thanks a lot, Michael! I had forgotten about this method, which is one of the finest approaches when having to build up nested groups. In the last days, I have been successful in applying this technique.

David Carlisle wrote:

> key returns a sequence of nodes you still need to use a choose (or
> apply templates) to cause any action to be taken with those nodes.

Thank you, David. I somehow had a wrong idea about the way keys are working. (And I'm sorry for having forged an incorrect test expression.) Using group-specific moded templates like Michael suggested is a much more elegant way of despatching than the case distinctions I thought of first.


Current Thread