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

recursive counter not incrementing

Subject: recursive counter not incrementing
From: Christopher Hansen <chansen1@xxxxxxxxx>
Date: Wed, 8 Dec 2004 17:21:22 -0500
recursive counter
Essentially i'm trying to use recursion to implement a counter in this manner:
while counter != number of items counted in each itemset (itemsets.xml)
 {
   If there is any occurrance of item[counter] in the transaction list
       counter++;
 }

However, my output shows that my counter increments from 0 to 1 once
and only once.
(XML source at the bottom)
Thanks,
Chris

<xsl:key name="coupKey" match="frequent_item_sets/set" use="item"/>
<xsl:variable name="transitems1"
select="document('transactions.xml')//transaction[1]" />

<xsl:output method="html"/>

<xsl:template match="/">

   <xsl:variable name="set1"
select="key('coupKey',$transitems1/items/item[1])" />
   <xsl:variable name="set2" select="$transitems1/items" />

<xsl:call-template name="subset">
    <xsl:with-param name="s1" select="$set1"/>
    <xsl:with-param name="s2" select="$set2"/>
    <xsl:with-param name="itemcount" select="count($set1/item)"/>
    <xsl:with-param name="i" select="0"/>
</xsl:call-template>

<xsl:template name="subset">
    <xsl:param name="s1"/>
    <xsl:param name="s2"/>
    <xsl:param name="itemcount"/>
    <xsl:param name="i"/>

   <!-- $itemcount will be '3' -->
   <p><xsl:value-of select="$itemcount"/></p>
   <p><xsl:value-of select="$i"/></p>

 <xsl:if test="$i != $itemcount">

    <xsl:for-each select="$s1/item">
       <xsl:variable name="sub1" select="."/>

       <xsl:for-each select="$s2/item">
         <xsl:if test="$sub1 = . ">

          We have a match!

              <xsl:call-template name="subset">
              <xsl:with-param name="s1" select="$s1/item[following-sibling]"/>
              <xsl:with-param name="s2" select="$s2"/>
              <xsl:with-param name="itemcount" select="$itemcount"/>
              <xsl:with-param name="i" select="($i)+1"/>
              </xsl:call-template>

         </xsl:if>
       </xsl:for-each>
    </xsl:for-each>
   </xsl:if>
 </xsl:template>
</xsl:stylesheet>

---------------------------------
itemsets.xml:

<frequent_item_sets>
  <set id="1" coupon="50 cents">
        <item>Milk</item>
        <item>Butter</item>
        <item>Eggs</item>
 </set>
......

transactions.xml:

<transactions>
 <transaction>
   <customer>
       <name>Dan</name>
       <email>asdf@xxxxxxxx</email>
   </customer>
   <items total="$11.78">
       <item>Milk</item>
       <item>Butter</item>
       <item>SuperPretzel</item>
       <item>Paper Towel (Scott's)</item>
  </items>
</transaction>
......

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.