Re: [xsl] OR in test

Subject: Re: [xsl] OR in test
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 4 Jul 2002 13:48:52 +0100
Hi Ashu,

> but it is not working .i want to know that is it wrong to use or(|)
> in test.if yes then what should be the right way.

In XPath, 'or' is 'or'. '|' is the union operator, which unions
together two or more node sets to create another one. (This sometimes
gives the same result as 'or', but that's because when you test a node
set, it's "true" when the node set has a node in it and false
otherwise.)

So use:

  <xsl:if test="$type='text' or $type='password'">
    ...
  </xsl:if>

> and what if in html text is written as TEXT(in capitals). as in wml
> only two (text and password) input types are allowed

Then you need to test whether $type, converted to lowercase, is 'text'
or not. You can convert to lowercase using the translate() function.
Perhaps you want:

  <xsl:if test="translate($type, 'TEX', 'tex')='text' or
                translate($type, 'PASWORD', 'pasword')='password'">
    ...
  </xsl:if>

Cheers,

Jeni

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


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


Current Thread