SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)

    XSL Ternary Logic

    Can someone explain to me why this is not allowed and suggest an alternative. I understand that I could use the xpath if. However, I have to stick to XPath 1.0 for this.

    Thanks

    Code XSL:
    		<xsl:choose>
    			<xsl:when test="$found_rows &lt; $limit">
    				<xsl:variable name="pages" select="1"/>
    			</xsl:when>
    			<xsl:otherwise>
    				<xsl:variable name="pages" select="ceiling($found_rows div $limit)"/>
    			</xsl:otherwise>
    		</xsl:choose>
    The only code I hate more than my own is everyone else's.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Wow that was quick. Apparently the solution is outlined on the w3c schools xsl:choose page at the very bottom.

    Code XSL:
    		<xsl:variable name="pages">
      			<xsl:choose>
        			<xsl:when test="$found_rows &lt; $limit">
         				 <xsl:value-of select="1"/>
        			</xsl:when>
       	 			<xsl:otherwise>
       	 				<xsl:value-of select="ceiling($found_rows div $limit)"/>
       	 			</xsl:otherwise>
      			</xsl:choose>
    		</xsl:variable>
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •