View Single Post
  #1 (permalink)  
Old March 21st, 2007, 08:15 AM
Tre Tre is offline
Authorized User
 
Join Date: Mar 2007
Location: Phila, PA, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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"/>
    <fo:instream-foreign-object>
      <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"/>
              </text>
            </xsl:if>
          </xsl:for-each>
      </g>
    </svg>
  </fo:instream-foreign-object>
 </xsl:template>
Reply With Quote