[xsl] Setting a global variable, or using a variable in place of provided XML

Subject: [xsl] Setting a global variable, or using a variable in place of provided XML
From: dorian dorian <dorian37076@xxxxxxxxx>
Date: Wed, 24 Apr 2002 22:13:13 -0700 (PDT)
I'm new to xsl and have run into a problem which I'm
unable to solve on my own. I've been through the faq
and the list archives, but my general inexperience
with xsl prevents me from determining if one of the
faq answers can help me.

Here's my situation -

In my XML, I'm provided font sizing information as a
string, rather than a number, e.g. 'small', 'medium',
'large', etc.

For example,

<xsl:value-of select="//template/bodyfont/@size" />

Will contain either 'small', 'medium', 'large', etc.

For specific reasons, I need to declare my font sizes
as numbers, via <font size="1"> to maintain
consistency across the document.

I'd like to do something similar to -

<xsl:choose>
<xsl:when test="//template/bodyfont/@size = 'small'">
<xsl:variable name="bodyfontsize" select="'2'"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="bodyfontsize" select="'4'"/>
</xsl:otherwise>
</xsl:choose>

And later declare font sizes via <font
size={$bodyfontsize}> . Unfortunately, $bodyfontsize
does not appear to persist beyond the closing
xsl:choose. My XSL parser (sablotron) reports that the
variable does not exist. (I've tested this by placing
an <xsl:value-of select="$bodyfontsize" /> after the
closing xsl:choose above.)

I've tried a few different approaches, but none seem
to work as well as I believe xsl would allow.

Can anyone point me in the right direction, or offer a
suggestion? I'm generally self-reliant, but in this
case, I don't know enough about xsl to begin to know
where to look.

Any and all suggestions are appreciated.

-d

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/

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


Current Thread