This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Setting flags ?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]