Subject: Re: [xsl] Expanding Ranges From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 21 Mar 2009 08:20:53 +0100 |
>> <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" />
T:\ftemp>type mukul.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/"> <xsl:variable name="start" select="3"/> <xsl:variable name="end" select="5"/> <xsl:value-of select="for $i in $start to $end return concat('fig',$i)"/> </xsl:template>
T:\ftemp>xslt2 mukul.xsl mukul.xsl fig3 fig4 fig5 T:\ftemp>
-- XSLT/XSL-FO/XQuery training in Los Angeles (New dates!) 2009-06-08 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Expanding Ranges, Mukul Gandhi | Thread | Re: [xsl] Expanding Ranges, Mukul Gandhi |
Re: [xsl] Empty fo:block legal?, G. Ken Holman | Date | Re: [xsl] Expanding Ranges, Mukul Gandhi |
Month |