This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: comapring numbers with greater than and less than
- To: xsl-list at mulberrytech dot com
- Subject: Re: comapring numbers with greater than and less than
- From: Robert Koberg <rob at koberg dot com>
- Date: Mon, 21 Aug 2000 06:24:17 -0700
- References: <200008210107.TAA59348@skew.org>
- Reply-To: xsl-list at mulberrytech dot com
yea, I tried < but it does not work. any other ideas?
I will changet the division operator of course. hadn't gotten past my first
error...
----- Original Message -----
From: "Mike Brown" <mike@skew.org>
To: <xsl-list@mulberrytech.com>
Sent: Sunday, August 20, 2000 6:07 PM
Subject: Re: comapring numbers with greater than and less than
> Robert Koberg wrote:
> > How do you do something like this (which doesn't work because of the
> > < in the test)?
> > <xsl:if test="position()<($totalcount/2)">
>
> The < may be a problem, so replace it with <. The real problem is the
> /, which is not a division operator; it's a location step separator. Use:
>
> <xsl:if test="position() < $totalcount div 2">
>
> > I want to test for the number of items and put half into one column and
half
> > into the other column:
> >
> > if someone can tell me a better way I would be appreciative.
>
> <xsl:variable name="all_items"
select="//config/network/channel/features/item"/>
> <xsl:variable name="total" select="count($all_items)"/>
> <xsl:for-each select="$all_items[position() <= ceiling($total div 2)]">
<!-- could also do ceiling(last() div 2) -->
> <tr>
> <td>
> <xsl:apply-templates select="."/>
> </td>
> <xsl:variable name="this_pos" select="position()"/> <!-- relative to
the set in the xsl:for-each -->
> <xsl:variable name="next_item" select="$all_items[$this_pos +
floor($total div 2)]"/>
> <td>
> <xsl:choose>
> <xsl:when test="$next_item">
> <xsl:apply-templates select="$next_item"/>
> </xsl:when>
> <!-- no item for 2nd column, so just put non-breaking space -->
> <xsl:otherwise> </xsl:otherwise>
> </xsl:choose>
> </td>
> </tr>
> </xsl:for-each>
>
> - Mike
> ____________________________________________________________________
> Mike J. Brown, software engineer at My XML/XSL resources:
> webb.net in Denver, Colorado, USA http://www.skew.org/xml/
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list