Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:59 PM.


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