Re: [xsl] adding variables

Subject: Re: [xsl] adding variables
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Tue, 12 Mar 2002 22:35:06 +0100
Hi Bryan,

there are many different possible solutions.

> I want to have an offset stored so that I can move
> around all off my components based on this offset. I
> have created a variable:
>
> <xsl:variable name="y_offset">
>   <xsl:value-of select="20"/>
> </xsl:variable>

This can be shortened to <xsl:variable name="y_offset" select="20"/>

> and want to add to the offset. Something to the effect
> of:
>
> <path d="M 35, {$y_offset} + 25 ....

1. very close to the solution: <path d="M 35, {$y_offset + 25} ..."/>

> The output of this command is  20 + 25 though and not
> 45 like I would like it to be. I can't use the
> <xsl:valueof> because it is an attribute.

2. That's not quite correct:

<path>
    <xsl:attribute name="d">
        <xsl:text>M 35,</xsl:text>
        <xsl:value-of select="$y_offset + 25"/>
        ...
    </xsl:attribute>
</path>

But I would prefer the first method using attribute value template.

3. And a complete different solution using SVG: You must group all elements
with the $y_offset and translate() them:

<g transform="translate(0 {$y_offset})">
    <path d="M35,25 ..."/>
</g>

Maybe this is the cleanest and easiest solution.

Regards,

Joerg


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


Current Thread