This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XSLT/SVG variables question
- From: "James Fuller" <james dot fuller at o-idev dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sun, 1 Jul 2001 09:50:28 +0100
- Subject: Re: [xsl] XSLT/SVG variables question
- Organization: o-iDeveloper ltd.
- References: <Pine.GSO.4.33.0206301726360.27566-100000@cs1>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello Harry,
----- Original Message -----
From: "Harry J. Foxwell" <hfoxwell@cs.gmu.edu>
> I'm not quite convinced of 'Assignment Considered
> Harmful' (Kay, Chap 9) since I can't figure out how to solve my
> XSLT/SVG problem without good ol' x=x+y constructs.
well, this is a major tenet of FP, not an arguement but part of a very well
developed approach to computer languages, in heavy use ( in some circles, u
know who you are ! ) since the early 1970's.
> As the block chart is built, I need to account for arbitrary
> number of strings per block and number of blocks. "Normal"
> variables would let me compute and increment SVG coordinates
> for the rectangles and text. But XSLT variables aren't normal!
u can always use a recursive named template, here is an example of an
incrementing variable
<xsl:call-template name="for.loop">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="count">10</xsl:with-param>
</xsl:call-template>
<!-- Rename "old name" elements to "new name" -->
<xsl:template name="for.loop">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:if test="$i <= $count">
<!-- body of the loop goes here -->
</xsl:if>
<xsl:if test="$i <= $count">
<xsl:call-template name="for.loop">
<xsl:with-param name="i">
<!-- Increment index-->
<xsl:value-of select="$i + 1"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
you will most likely have to apply something like this
cheers, jim fuller
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list