xsl-list
[Top] [All Lists]

Re: [xsl] Expanding Ranges

2009-03-21 02:07:29
On Sat, Mar 21, 2009 at 10:53 AM, Ganesh Babu N 
<nbabuganesh(_at_)gmail(_dot_)com> wrote:
Thanks Mukul,

I got the solution.

I find it surprising if the solution I proposed works as it is.

<xsl:value-of select="for $i in $start to $end return concat('fig', $i)"/>

I suspect if this will give the desired result.

If you see the grammar for a "for expression"
(http://www.w3.org/TR/xpath20/#id-for-expressions),

it doesn't allow something like, $x to $y (with the semantics of a
range. xsl:for-each allows this).

Saxon (ver, 9.1.0.2J) compiles the above for expression {for $i in
$start to $end return concat('fig', $i)} fine, but gives a blank
output. It seems, it considers _$start to $end_ as ExprSingle (ref:
http://www.w3.org/TR/xpath20/#doc-xpath-ExprSingle). It seems to me,
Saxon should give an error or a warning in this case.

I feel you should use the following code, instead:

<xsl:variable name="str" as="xs:string*">
    <xsl:for-each select="$start to $end">
       <xsl:value-of select="concat('fig', .)" />
    </xsl:for-each>
</xsl:variable>

<xsl:value-of select="$str" />


-- 
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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