Re: [xsl] xsl:when - comparing parameter and element values

Subject: Re: [xsl] xsl:when - comparing parameter and element values
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 6 Jan 2001 11:34:59 +0000
Hi Edith,

> I can't get the right syntax for the comparison between the two
> values for xsl:when. What I want to test is when the 'showcasemgmt'
> parameter contains the value "true" and the element 'casemgmtind'
> contains the value "FALSE".

You're using:

  $showcasemgmt='true' && CaseMgmtInd='FALSE'

which is *almost* right, except that '&&' isn't valid XPath syntax.
You want to use 'and' instead:

  $showcasemgmt='true' and CaseMgmtInd='FALSE'

Similarly, XPath uses 'or' for or and not() for not and so on.
Guessing at syntax is always problematic.

> The second part to my question is...only if this case is NOT
> satisfied, do I want to output a <tr>, if I leave the contents of
> the "when" empty, will that work?

You're using:

    <xsl:when test="$showcasemgmt='true' and

That's fine, and it will work, but you might be interested in an
alternative that's a bit shorter. You're only wanting to do something
if it's *not* the case that $showcasemgmt is 'true' and CaseMgmtInd is
'FALSE', and that's all you're concerned about testing, so you can
just use xsl:if instead:

  <xsl:if test="not($showcasemgmt = 'true' and
                    CaseMgmtInd = 'FALSE')">

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread