[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: adding multiple variables to a complex condition

Subject: Re: adding multiple variables to a complex condition
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 10 Dec 2001 11:02:19 +0000
adding multiple variables
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.