This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: SETS comparison..?
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Martijn" <rootroot at xs4all dot nl>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 23 Jan 2002 17:19:47 +0000
- Subject: Re: [xsl] SETS comparison..?
- Organization: Jeni Tennison Consulting Ltd
- References: <000901c1a457$832589f0$0a00a8c0@earth>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Martijn,
> Is it possible to group values not having to repeat the same
> attribute over and over?
>
> e.g.: <xsl:if test=". in ['a', 'b', 'd']">
In XPath 1.0, you have to do:
. = 'a' or . = 'b' or . = 'd'
Another option is to create a node set containing the values that
you're interested in, and use the existential semantics of = to do the
test. So if you have $values be set to a node set that contains the
following elements:
<value>a</value>
<value>b</value>
<value>d</value>
then you can just do:
. = $values
Creating the node set is a little tricky - you can put the XML in a
separate document or embed it in the stylesheet, and use the
document() function to access it; or you can create a variable holding
a result tree fragment with those value elements in it, and then
convert that to a node set with a implementation-specific node-set()
extension function.
---
This all becomes a lot easier in XPath 2.0. With XPath 2.0, you just
do:
. = ('a', 'b', 'd')
and there you have it.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list