This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: choose/when question
- To: Jo Bourne <venus at va dot com dot au>
- Subject: Re: [xsl] choose/when question
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 22 Aug 2001 10:26:26 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <a05100300b7a8dfe84833@[10.0.1.51]>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Jo,
> the result of the two when statements are identical, it is only the
> otherwise that has different behaviour. I am wondering if it would
> have any noticible effect on performance to combine the two when
> statements into one? and if it would how would i do this? is like
> this:
It probably wouldn't have any noticeable effect on performance, but it
would make your stylesheet more maintainable. You can combine the two
conditions with an 'or', as follows:
<xsl:choose>
<xsl:when test="@number = 'one' or @number = 'two'">
...
</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
There's no simple way of checking whether the value of @number is in a
list in the way that you tried, although you could hold them in some
XML and test against that, or you could do something like:
contains(':one:two:', concat(':', @number, ':'))
The separate tests are probably clearer unless you have a large number
of possible values.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list