RE: [xsl] RE: Last () -1

Subject: RE: [xsl] RE: Last () -1
From: "John Reid" <John.Reid@xxxxxxxxxxxxxxx>
Date: Sat, 4 Oct 2003 22:07:43 +1000
G'day David, (well actually it is 10PM)

I have only given four days, but in fact there is 40 days (8 weeks). I
want to pick off the last 5 days and work out which of those is the
smallest. So perhaps, I should say:

<xsl:variable name="varL5">
<xsl:for-each select="day[position() &gt; 35 and position() &lt; 41]">
<xsl:sort select="cl"  order="descending" data-type="number"/>
<xsl:if test="position()=last()"><xsl:value-of select="cl" /></xsl:if>
</xsl:for-each>
</xsl:variable>

I then want to back off a day and get the next five and get the smallest

<xsl:variable name="varL51">
<xsl:for-each select="day[position() &gt; 34 and position() &lt; 40]">
<xsl:sort select="cl"  order="descending" data-type="number"/>
<xsl:if test="position()=last()"><xsl:value-of select="cl" /></xsl:if>
</xsl:for-each>
</xsl:variable>

I then want to back off another day and get the next five and get the
smallest

<xsl:variable name="varL52">
<xsl:for-each select="day[position() &gt; 33 and position() &lt; 39]">
<xsl:sort select="cl"  order="descending" data-type="number"/>
<xsl:if test="position()=last()"><xsl:value-of select="cl" /></xsl:if>
</xsl:for-each>
</xsl:variable>

I thought it might be safer(ie data problems would be less) to start at
the end as the starting point, that's y I was going to use last(),
last()-1, last()-2 for variable varL5, varL51, varL52 respectively

What do u think?

John

You have four day elements so


<xsl:for-each select="day[position() &gt; last()-3 and position() &lt;
last()-1]">

is

<xsl:for-each select="day[position() &gt; 1 and position() &lt; 3]">

The first clause isn't a constraint as position is always greater than 1
so this is

<xsl:for-each select="day[position() &lt; 3]">

so you just select the first two days then sort them in descending order
of cl and take the last in sorted order, so that would give

6500

You said you wanted 6200 but haven't specified the transform that you
want to produce taht so I can't suggest changes to teh xsl.

David


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread