[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Passing parameters between different occurrences of th

Subject: Passing parameters between different occurrences of the same template
From: Ranajay Raychaudhuri <raychaur@xxxxxxxxxxxx>
Date: Fri, 17 Aug 2001 16:23:57 +0100
passing parameters to svg
Dear All,

I am trying to draw a 2D linear graph using SVG.
My code  looks like this:


<xsl:template.....>
........
        <xsl:for-each select="output">
          <xsl:apply-templates select=".">

        <xsl:with-param name="x_offset">
             <xsl:choose>
              <xsl:when test="position() = 1">
                   <xsl:value-of select="'80'"/>
              </xsl:when>
              <xsl:otherwise>
                   <xsl:value-of select="80 + (prog_vel/.)*50"/>
              </xsl:otherwise>
             </xsl:choose>
    </xsl:with-param>

    <xsl:with-param name="y_offset">
         <xsl:choose>
          <xsl:when test="position() = 1">
               <xsl:value-of select="'600'"/>
          </xsl:when>
          <xsl:otherwise>
               <xsl:value-of select="600 - (cor_time/.)*50"/>
          </xsl:otherwise>
        </xsl:choose>
    </xsl:with-param>

     </xsl:apply-templates>

 </xsl:for-each>
 </svg>
 </xsl:template>


<xsl:template match="output">

    <xsl:param name="x-offset" select="'80'"/>
    <xsl:param name="y-offset" select="'600'"/>


 <xsl:variable name="x_cord">
      <xsl:value-of select="80 + (prog_vel/.)*50"/>
    </xsl:variable>

    <xsl:variable name="y_cord">
      <xsl:value-of select="600 - (cor_time/.)*50"/>
    </xsl:variable>


    <path>
      <xsl:attribute name="style">
        <xsl:text>stroke-width:2; stroke:black; fill:black</xsl:text>
      </xsl:attribute>
      <xsl:attribute name="d">

        <xsl:text>M </xsl:text>
        <xsl:value-of select="$x_offset"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="$y_offset"/>
        <xsl:text> L </xsl:text>
        <xsl:value-of select="$x_cord"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="$y_cord"/>
...
</xsl:template>

My problem is that I need to pass the values of x_cord and y_cord in one
template to the next call of the template in the for-each loop, so that
the generated code would look like:

<path style="stroke-width:2; stroke:black; fill:black" d="M 80 600 L 250
540 Z"/>
<path style="stroke-width:2; stroke:black; fill:black" d="M 250 540 L
370 375 Z"/>

i.e, the values associated with the L command in the 1st <path> stmt.,
are associated with the M command in the next <path> stmt.

Right now predictably this is what it the generated path stmts. look
like:

<path style="stroke-width:2; stroke:black; fill:black" d="M 80 600 L 250
540 Z"/>
<path style="stroke-width:2; stroke:black; fill:black" d="M 370 375 L
370 375 Z"/>


My XML looks like:


<XEX-data>
  <output>
        <prog_vel>3.4</prog_vel>
        <cor_time>1.2</cor_time>
  </output>
  <output>
        <prog_vel>5.8</prog_vel>
        <cor_time>4.5</cor_time>
  </output>
</XEX-data>

I can't find a way around this. Please help.

Thanks,
Ron


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.