Re: [xsl] Parameter Type problem

Subject: Re: [xsl] Parameter Type problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 25 Jan 2002 18:24:36 +0000
Hi Karen,

> The problem is the parameter is then of string type and not node...
> How can I "cast" it to a node?

I'm afraid that in XSLT 1.0 you can't simply cast it to a node,
because to do so, the processor would have to dynamically evaluate the
expression that you'd just constructed.

There are two ways that you can get round this, though. The first is
to use an evaluate() extension function to do the 'cast'. The
evaluate() extension function that you use depends on your processor:
in Saxon it's saxon:evaluate(), in Xalan it's xalan:evaluate(), in
MSXML you have to write your own.

The second way around in this case is to use a path of the form:

  @*[name() = $name]

In other words, select those attributes whose name is the same as the
value of the $name parameter.

In fact, because the $tmplg parameter starts with a '@' you need
to do one of the following:

 - don't add the '@' at the beginning of $tmplg in the first place and
   then use @*[name() = $tmplg]
 - use @*[concat('@', name()) = $tmplg]
 - use @*[name() = substring($tmplg, 2)]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread