Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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>
  #2 (permalink)  
Old March 21st, 2007, 09:31 AM
Registered User
 
Join Date: Jul 2006
Location: Forest Hills, NY, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Incrementing the variable value Swetha XSLT 2 April 28th, 2008 04:43 PM
Incrementing attribute value Pankaj C XSLT 4 October 31st, 2007 05:40 AM
reading and incrementing a value phantom3008 ASP.NET 1.0 and 1.1 Basics 0 April 18th, 2007 10:29 AM
For Loop Not incrementing donrafeal7 Javascript 1 October 24th, 2006 12:24 AM
incrementing value of a variable akibaMaila VB.NET 2002/2003 Basics 4 July 5th, 2005 12:04 PM





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