RE: [XSLT] Nullifying the "current template rule" in xsl:for-each

The reason for the restriction is that inside xsl:for-each, the context item
changes: so what would node would xsl:next-match be processing? This would
require augmenting the dynamic context with a "current matched item" which
isn't changed by xsl:for-each. It's not clear that there's a net usability
benefit in making the context even more complicated than it is already.

(Personal response)

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: public-qt-comments-request@w3.org 
> [mailto:public-qt-comments-request@w3.org] On Behalf Of Evan Lenz
> Sent: 08 May 2010 01:32
> To: public-qt-comments@w3.org
> Subject: [XSLT] Nullifying the "current template rule" in xsl:for-each
> 
> Hello,
> 
> In a future version, it would be nice to see this restriction 
> relaxed, i.e. keep the "current template rule" around even 
> when inside <xsl:for-each>. This makes <xsl:next-match/> much 
> more useful (such as when duplicating an element in the 
> result that only appears once in the source document.)
> 
> E.g., given the identity transformation as the default 
> template rule, it would be nice to be able to do this:
> 
> <xsl:template match="*[@duplicate-me eq 'yes']">
>   <xsl:for-each select="1 to @how-many">
>     <xsl:next-match/>
>   </xsl:for-each>
> </xsl:template>
> 
> This example is simplistic, but I do have a real use case 
> (mapping multi-valued HTTP request parameters to a repeating 
> element in an XML template). And I've run into this 
> restriction before (when wanting to use <xsl:apply-imports/> 
> inside <xsl:for-each>).
> 
> Evan
> 
> --
> Evan Lenz
> Lenz Consulting Group, Inc.
> http://lenzconsulting.com
> +1 (360) 297-0087
> 

Received on Saturday, 8 May 2010 09:10:50 UTC