|
Subject: Re: [xsl] adding multiple variables to a complex condition From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 10 Dec 2001 11:02:19 +0000 |
Hi Eric,
> What is a good way to add other variables like output2 .. $outputn
> to this conditional?
Yes. Use an XML structure to hold the various names:
<output>output1</output>
<output>output2</output>
...
<output>outputN</output>
Hold these output elements in a node set called $outputs. This enables
you to check if *any* or *none* of the outputs fulfil certain
conditions, because it's easy to check whether *any* or *no* node
fulfils conditions. For example:
$outputs = 'all'
would check whether *any* output had the value 'all'.
How you get the $outputs variable holding those output elements is up
to you. The purest way would be to put them in a separate document or
in the stylesheet and use the document() function to get at them.
Alternatively, you could build a variable and an extension node-set()
function to get at them.
I'm not sure that I follow the logic of your condition, but I think
you want something like the following:
<xsl:template name="conditional">
<xsl:variable name="include" select="@include" />
<xsl:variable name="exclusive" select="@exclusive" />
<xsl:variable name="reject" select="@reject" />
<xsl:choose>
<xsl:when test="
$outputs = 'all' or
((ancestor::*|@*)[name() = $outputs] or
$outputs[contains($include, .)] or
$outputs[contains($exclusive, .) and
not(contains($reject, .))] and
not($reject = 'all'))">yes</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Note that you need to do $outputs[contains($include, .)] rather than
contains(@include, $outputs) because the contains() function converts
the second argument to a string, so contains(@include, $outputs) would
test whether the include attribute contains the first output, not any
of the others.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] format numbers, Jörg Heinicke | Thread | [xsl] newbie: xsl:key and summation, Christopher Giblin |
| Re: [xsl] XML elments order, Jeni Tennison | Date | Re: [xsl] whitespaces, Pep Coll |
| Month |