RE: How to use Multi-value Variables?

Subject: RE: How to use Multi-value Variables?
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 17 Jul 2000 10:01:38 +0100
> I've defined a variable:
> <xsl:variable name="NewDBMS">
>      <Driver>....</Driver>
>      <Server>....</Server>
>      <Owner>.....</Owner>
> </xsl:variable>
> 
> This variable works fine, in that I can take the <xsl:value-of
> select="$NewDBMS/Server" />

If this works, then you're probably using MSXML3, because it relies on the
implicit conversion of a result tree fragment to a node-set. XSLT 1.0
specifically states that the "/" path operator can't be used with a
result-tree-fragment argument.

> The next problem is to build a template that matches all 
> children of Database ... where there is also a child [of] $NewDBMS with
the same 
> name.  It [seems] that an <xsl:template  match=... /> statement does not 
> allow for variables.

Correct, variables can't be used in template rules. This is to prevent
recursion: a global variable declaration might invoke the template, so which
comes first?

The match pattern must be fixed "at compile time", it can't depend in any
way on the source document. It might be possible to achieve what you want
using the name() function, but that doesn't help much because you'd probably
want to compare the name with a variable.

Mike Kay
PS glad you like the book 


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


Current Thread