p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Incrementing a value within a template (http://p2p.wrox.com/showthread.php?t=55668)

Tre March 21st, 2007 08:15 AM

Incrementing a value within a template
Hi All,

I have a template that I have written in XSLT that has some embedded SVG that draws a bar graph that relates to data wihin my .xml document.

The template draws the bar graph fine except that I cant increment a value to move the "pen" across the page so all the bars get rendered onto of each other which is no good at all.

I have tried using the XSLT position() function which works great for the first few records that contain the same customer. But as soon as a new customer comes along in my record set I want to be able to reset the "pen" and start drawing the graph again on the left hand side of the screen.

Any ideas that you could offer me would be greatly appreciated.

Please find my template below and note that the $count parameter within the SVG is the parameter that I need to increment and reset after each call to the barChart template.

  <xsl:template name="barChart">
    <xsl:param name ="count"/>
    <xsl:param name="currentSecurity"/>
    <xsl:param name="precedingSecurity"/>
      <svg width="400px" height="400px" xmlns="http://www.w3.org/2000/svg">
        <g id="BarChart" transform="translate(0,100) scale(1.5)">
          <xsl:for-each select="$source">
            <xsl:if test="number(PortfolioID) = $currentSecurity -1">
              <xsl:variable name="val" select="Quantity"/>

              <rect x="{$count*25}" y="-{$val div 10}" height="{$val div 10}" width="15" stroke = "red" fill = "forestgreen"/>
              <text x="{$count*25 + 7.5}" y="0" style="font-family:arial;text-anchor:middle;baseline-shift:-15;$pagePosition = $pagePosition+1">
                <xsl:value-of select="./Description"/>

the cause March 21st, 2007 09:31 AM

if x isn't incrementing by 25, then $count is a constant value.

assuming u posted only relevant xsl, it looks like your count param is just text instead of a function.

All times are GMT -4. The time now is 04:13 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.