This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: (or) statement in setting node-set variable
- To: "Keith" <keith at brooksweb dot com>
- Subject: Re: [xsl] (or) statement in setting node-set variable
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Sat, 6 Jan 2001 10:43:08 +0000
- CC: "Xsl-List (E-mail 2)" <xsl-list at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <000301c07768$1c9e89b0$8264a8c0@dev001>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Keith,
> <xsl:variable name="ReportList"
> select="msxsl:node-set($ReportList-rtf)//GetMerchantReportList|
> msxsl:node-set($ReportList-rtf)//GetLocationReportList"/> ??
I'm 90% sure that this does what you're trying to achieve. This is
valid syntax if you want to set the $ReportList variable to a node set
that results from the union of the GetMerchantReport elements and the
GetLocationReportList elements in the node set generated by
interpreting $ReportList-rtf as a node set.
Alternative syntax for the select expression if that is what you want
to achieve is:
msxsl:node-set($ReportList-rtf)//*[self::GetMerchantReportList or
self::GetLocationReportList]
This collects all the node elements in the node set generated by
interpreting $ReportList-rtf as a node set that are themselves
GetMerchantReportList elements or GetLocationReportList elements. This
is *probably* better in that the $ReportList-rtf result tree fragment
only has to be converted to a node set once.
[Aside: within a boolean context, like a predicate or a test on xsl:if
or xsl:when, 'or' and the union operator '|' give the same
functionality: if either of the node sets have any nodes in them, then
the test will return true. I think it's slightly better to use 'or'
because the processor can stop testing and return true if the first
node set has any nodes in it, rather than having to construct two node
sets every time.]
Now you say that the content of this node set needs to depend on the
value of some parameter in the stylesheet, and that you could be
interested in only GetMerchantReportList items, in only
GetLocationReportList items or in both.
If the parameter gives the name of the elements that you're after,
then you could use:
msxsl:node-set($ReportList-rtf)//*[local-name() = $ElementName]
If you need to test the parameter in other ways, then you could use
something like:
msxsl:node-set($ReportList-rtf)//*
[self::GetMerchantReportList[...condition...] or
self::GetLocationReportList[...condition...]]
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list