This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:when - comparing parameter and element values
- To: "RUSSO, EDITH" <EDIRUS at SAFECO dot com>
- Subject: Re: [xsl] xsl:when - comparing parameter and element values
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Sat, 6 Jan 2001 11:34:59 +0000
- CC: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <D1CF927198C7D11198A50001FAD456540C6F4DDB@hoxsv027.safeco.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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:choose>
<xsl:when test="$showcasemgmt='true' and
CaseMgmtInd='FALSE'"></xsl:when>
<xsl:otherwise>
<tr>...</tr>
</xsl:otherwise>
</xsl:choose>
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')">
<tr>...</tr>
</xsl:if>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list