This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Params being intialised with variables based on attributes


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]