[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Counting Nodes Based on Conditional Statements

Subject: Re: Counting Nodes Based on Conditional Statements
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Sat, 30 Oct 2004 17:36:35 +0200
xsl count nodes
Hi Michael,

 <xsl:template match="/">
   <div class="line"></div>

<xsl:for-each select="catalog/category/topic/book">
<xsl:sort select="title" data-type="text" order="ascending" />
<xsl:if test="$status = 'All' or ($status = 'Purchased' and @status = 'Purchased')">
<xsl:if test="$category = 'All' or ($category = ../../@name and ($topic = ../@name or $topic = 'All'))">
<div><xsl:value-of select="title" /></div>
<div class="line"></div>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>

You could _first_ determine the list catching it in a variable and _then_ get the count and loop over them.


<xsl:variable
    name="books"
    select="catalog/category/topic/book
                [$status = 'All'
                  or ($status = 'Purchased' and @status = 'Purchased')]
                [$category = 'All'
                  or ($category = ../../@name and ($topic = ../@name or $topic = 'All'))]" />

(sorry for the silly indentation)

<xsl:choose>
  <xsl:when test="count($books) = 0">
    <!-- sorry no books -->
  </xsl:when>
  <xsl:otherwise>
    <!-- count($books) shown! -->
    <xsl:for-each select="$books">
      <!-- presentation of books -->
    </xsl:for-each>
  </xsl:otherwise>
</xsl:choose>

Grtz,
Geert

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.