This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: comapring numbers with greater than and less than


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
> > &lt; in the test)?
> > <xsl:if test="position()<($totalcount/2)">
>
> The < may be a problem, so replace it with &lt;. The real problem is the
> /, which is not a division operator; it's a location step separator. Use:
>
> <xsl:if test="position() &lt; $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() &lt;= 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>&#160;</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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]