Re: xsl:when, using AND

Subject: Re: xsl:when, using AND
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 22 Aug 2000 08:12:16 +0100
Russ,

><xsl:choose>
><xsl:when test="((//CUSTOM/F128[. = '1']) $and$ (//CUSTOM/F129[. $ne$
>'1']))">
[snip]
>
>but I get 'Unspecified error..' - useful!?

The fact that you're using $and$ and $ne$ implies that you are using an old
version of the MSXML processor, or that you were using an old version and
have changed to a new one without updating your code.  See the Unofficial
MSXML FAQ at http://www.netcrucible.com/xslt/msxml-faq.html.  Hopefully
that will clear up your unspecified error.

'$and$' should be changed to 'and' and '$ne$' should be changed to '!=',
giving the test expression:

  ((//CUSTOM/F128[. = '1']) and (//CUSTOM/F129[. != '1']))

However, you should also be aware of what you're actually testing for here.
 You are asking the question "is it the case that there is a F128 element
whose value is equal to '1' under a CUSTOM element anywhere in the source,
and a F129 element whose value is not equal to '1' under a CUSTOM element
anywhere in the source?"

I think that what you're actually interested in is checking the value of
the elements that you know exist rather than finding out whether any
elements exist with those particular values.  In other words, you want to
ask the question "is it the case that the F128 element under the CUSTOM
element anywhere in the source has a value equal to '1' and that the F129
element under the CUSTOM element anywhere in the source has a value not
equal to '1'?  This gives the expression:

  (//CUSTOM/F128 = '1') and (//CUSTOM/F129 != '1')

[you don't actually need the brackets, but you seemed fond of them ;)]

The XPaths you're using are obviously examples, but just to point out that
both tests rely on there being only a single F128 and a single F129 element
underneath a CUSTOM element anywhere in the document.

I hope that this helps,

Jeni

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


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


Current Thread