W3C home > Mailing lists > Public > public-qt-comments@w3.org > May 2010

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

From: Evan Lenz <evan@evanlenz.net>
Date: Sat, 08 May 2010 03:10:52 -0700
Message-ID: <4BE538AC.9070802@evanlenz.net>
To: Michael Kay <mike@saxonica.com>
CC: public-qt-comments@w3.org
Your point is well taken, but I'm not sure that augmenting the context 
would have any usability cost. From this user's perspective, it seems 
like an arbitrary omission. It's not as if there's a question of 
ambiguity. You always simply look at the match pattern to see what the 
current matched item is...

Hmm, you didn't say "current matched node". Does that mean we can match 
simple values in a future version? (Yes, please.)

Evan


Michael Kay wrote:
> 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
>>
>>     
>
>   


-- 
Evan Lenz
Lenz Consulting Group, Inc.
http://lenzconsulting.com
+1 (360) 297-0087
Received on Saturday, 8 May 2010 10:11:21 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:42 UTC