[xsl] xsl:for-each is not a loop <-- right?

Subject: [xsl] xsl:for-each is not a loop <-- right?
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Feb 2025 22:12:14 -0000
Hi Folks,

Suppose that I create a parameterized boolean function which tests its
parameter to see if it is greater than zero:

<xsl:function name="f:GT_Zero" as="xs:boolean">
    <xsl:param name="value"/>
    <xsl:sequence select="$value gt 0"/>
</xsl:function>

I call it with a list of values:

<xsl:sequence select="f:GT_Zero(1)"/>
<xsl:sequence select="f:GT_Zero(2)"/>
<xsl:sequence select="f:GT_Zero(3)"/>

Here is a shorthand for that:

<xsl:for-each select="(1,2,3)">
    <xsl:sequence select=". gt 0"/>
</xsl:for-each>

xsl:for-each is not a loop.

xsl:for-each is a shorthand for applying an expression to each item in a list.

In this example, the Boolean expression $value gt 0 is applied to each item in
the list (1, 2, 3).

Do you agree?

/Roger

Current Thread