[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: adding multiple variables to a complex condition
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|