xsl-list
[Top] [All Lists]

[xsl] Keeping a running total?

2006-07-10 10:12:19
Problem:  I need to make a table of the output required of 4 factories
next month.

                 Widgets    Gadgets
Factory A     2
Factory B     3
Factory C                       4
Factory D                       1

Widget quota = 5
Gadget quota = 5

---

My current xsl looks something like.

<xsl:for-each select="document('factories.xml')//factory">
      <xsl:variable name="widgets">
            Has quota been reached? Then return 0.
            Otherwise, give as many possible without going over the quota.
      </xsl:variable>
      <xsl:variable name="gadgets">
             Has the widget quota been filled?
             Then start making gadgets!
              Has this quota been reached? (etc).
      </xsl:variable>
        <tr>
                <td><xsl:value-of select="@name" /></td>
                <td><xsl:value-of select="$widgets" /></td>
                <td><xsl:value-of select="$gadgets" /></td>
        </tr>
</xsl:for-each>

**Lines which I can't describe in XSL have been translated to English 3.1b

----------

When the quota of Widgets has been reached, I need the factories to
start making Gadgets. In the above example the quota is reached at
factory B and factory C begins making Gadgets.

Howto?

-Steve

PS: For now I am using a for-each (factory) to iterate through the
totals and generate numbers. It seems that templates are beneficial
for things such as this, but I have not yet mastered their use and so
if this can be more easily done with templates, I'd like to know how.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--