W3C home > Mailing lists > Public > public-qt-comments@w3.org > May 2003

Re: TR/xquery-operators/#func-doc

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 14 May 2003 09:54:04 +0100
Message-ID: <156-1267704663.20030514095404@jenitennison.com>
To: David.Pawson@rnib.org.uk
CC: public-qt-comments@w3.org

Hi Dave,

>> However, the need for this coding technique will greatly decline in
>> XSLT 2.0. It was used in XSLT 1.0 almost exclusively to handle
>> fixed look-up tables, which can be handled in XSLT 2.0 much more
>> efficiently using temporary trees held in global variables.
>
> The classic of 
> <months>
>  <January>
>  ...
>
> as a look up. 
>
> I can't see how a temporary tree will help there?

Rather than using the above (or the above with namespaces) as data
elements in your stylesheet and then doing something like:

  <xsl:value-of select="name(document('')/*/my:months/*[$monthNum])" />

you would declare a global variable:

<xsl:variable name="months">
  <January />
  ...
</xsl:variable>

and then do:

  <xsl:value-of select="name($months/*[$monthNum])" />

Now that we don't have result tree fragments, defining a tree in a
variable (a temporary tree) and accessing information from that tree
is very easy.

Like Mike, I expect that this will be used in preference to the
document('') method as it's much less fiddly and works well across
multiple stylesheet modules.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 14 May 2003 04:54:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:24 GMT