Subject: Re: comapring numbers with greater than and less than From: Mike Brown <mike@xxxxxxxx> Date: Sun, 20 Aug 2000 19:07:10 -0600 (MDT) |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
comapring numbers with greater than, Robert Koberg | Thread | Re: comapring numbers with greater , Robert Koberg |
Identity stylesheet, Danny Vint | Date | Re: dtd2xsl Program Written in Omni, Marcus Carr |
Month |