|
Subject: Re: [xsl] use variable in <xsl:if test= From: Matt Gushee <mgushee@xxxxxxxxxxxxx> Date: Fri, 1 Mar 2002 16:33:03 -0700 |
On Sat, Mar 02, 2002 at 12:21:29AM +0100, Robert Sösemann wrote:
> How in the world ;-) can i use a variable in <xsl:if test=..>
>
> <xsl:variable name="condition" select="*[.//author='C. J. Date']"/>
>
> <xsl:template match="node()[name()=$entity]">
> <xsl:if test="boolean(string($condition))">
There is nothing syntactically wrong with this. It would help if
you explained what result you are expecting.
> This does not work neigther with
> {$condition}
It shouldn't. You can't use attribute value templates in <xsl:if test="">.
You just put the variable reference in the attribute value, as in your
example. And it's okay to use the variable as an argument to a function,
and to nest functions.
Maybe you just have the wrong idea about what your XPath expression
is doing. In particular, I can't see a reason why you would need to
use both boolean() and string(). If $condition is an empty node-set,
then both boolean($condition) and string($condition) should evaluate
to false.
Ah, wait. I think I see the problem. It looks like you are defining
the variable at the top level of the stylesheet, aren't you? In that
case, it's always going to be false. '*' means 'any child _element_
of the current context node'. At the top level of the stylesheet,
there are no child elements.
You should probably define the variable within a template, where you
have more context information to work with.
--
Matt Gushee
Englewood, Colorado, USA
mgushee@xxxxxxxxxxxxx
http://www.havenrock.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] use variable in <xsl:if test=, Robert Sösemann | Thread | Re: [xsl] use variable in <xsl:if t, Mike Brown |
| [xsl] use variable in <xsl:if test=, Robert Sösemann | Date | Re: [xsl] use variable in <xsl:if t, Thomas B. Passin |
| Month |