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

Re: (or) statement in setting node-set variable

Subject: Re: (or) statement in setting node-set variable
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 6 Jan 2001 10:43:08 +0000
msxsl node set variable
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


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.