Subject: [xsl] Passing parameters between different occurrences of the same template From: Ranajay Raychaudhuri <raychaur@xxxxxxxxxxxx> Date: Fri, 17 Aug 2001 16:23:57 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re^4: ?XSLT Repository?, by way of B. Tommie | Thread | [xsl] Using Position() to display r, Andrew Welch |
Re: [xsl] format-number usage on in, David_Marston | Date | [xsl] Using Position() to display r, Andrew Welch |
Month |