xsl-list
[Top] [All Lists]

Re: [xsl] for vs. for-each

2021-03-14 16:47:08
On Sun, 2021-03-14 at 20:09 +0000, Wendell Piez 
wapiez(_at_)wendellpiez(_dot_)com
wrote:
Hi,

Another way to gloss this is that while "$values[.]" doesn't have the
intended effect,

<xsl:for-each select="1 to count($values)">
    <xsl:variable name="p" select="."/>
    <xsl:sequence select="$values[$p]"/>
</xsl:for-each>

Oughta work just fine.

I've often wished for,
<xsl:for-each select="1to 20" at="pos">
as a short-cut for
  <xsl:variable  as="xs:integer" select="position()" />

by analogy with XQuery, for $i at $pos in $sequence return ...

But then, i tnd to try writing group by in XPath expressions too :)

Liam


-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>