This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Params being intialised with variables based on attributes
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "gary cor" <stuff4gary at hotmail dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 26 Jun 2002 15:53:16 +0100
- Subject: Re: [xsl] Params being intialised with variables based on attributes
- Organization: Jeni Tennison Consulting Ltd
- References: <F52nlT2NqFJ3sl3xbYi0000005e@hotmail.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Gary,
> I have many when test's to reference global variables in my code and
> I can't seem to find a way of optimising the code so I am wondering
> if someone can help.
One possibility would be to use a single variable holding an XML
structure rather than several variables holding individual values. For
example, you could have $column-numbers-rtf holding a result tree
fragment with elements whose names reflect the columns:
<xsl:variable name="column-numbers-rtf">
<avgroup>1</avgroup>
<gallery>2</gallery>
<free>3</free>
...
</xsl:variable>
and then have $column-numbers hold the elements with either:
<xsl:variable name="column-numbers"
select="exsl:node-set($column-numbers-rtf)/*" />
or:
<xsl:variable name="column-numbers"
select="document('')/xsl:variable[@name = 'column-numbers-rtf']/*" />
Then your parameter can simply get the value of the element in
$column-numbers whose name is the same as the value of the grouping
attribute of the mediaobject element:
<xsl:template match="mediaobject">
<xsl:param name="column-number"
select="$column-numbers[name() = current()/@grouping]" />
...
</xsl:template>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list