This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Setting flags ?
- From: "Carsten Klein" <carstenklein at yahoo dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 30 Jul 2002 07:12:45 +0200
- Subject: Re: [xsl] Setting flags ?
- References: <1027943173@scamp.org.uk>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi John,
the problem with the variable, is that is out of scope. It is valid only
within the <xsl:for-each/> loop or from within
templates being called either by <xsl:call-template/> or
<xsl:apply-templates/> with additional <xsl:with-param/>
instructions.
It is not valid when being used inside the <xsl:choose/> at the end of your
stylesheet.
One question: the <option/> nodes, which you intentionally left empty, are
they the same for all
of the matches/tests inside the <xsl:for-each/> loop ?
If so, then why don't you just rewrite the whole bunch of <xsl:when/>'s and
the likes to match the following, selecting
all the nodes you want to match into a node-set contained in a variable:
<xsl:variable name="matches"
select="index/indexitem[contains(@text,$searchValue1)
or contains(@text,translate($searchValue1,'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))
or
contains(@text,concat(translate(substring($searchValue1,1,1),'abcdefghijklmn
opqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),substring($searchValue1,2)))"/>
This should result in the variable $matches containing a node-set which
contains the nodes which match your query or
the empty node-set.
You would then be able to
<xsl:choose>
<xsl:when test="$matches">
<!-- there were some matches...-->
<xsl:for-each select="$matches/*">
<!-- ... -->
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!-- no matches found -->
</xsl:otherwise>
Haven't tested this though, but it should give you a hint into the right
direction, I suppose.
Bye
Carsten
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list