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

Re: RE: unbelievable often asked question

Subject: Re: RE: unbelievable often asked question
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 2 Jan 2003 11:38:50 -0700 (MST)
xpath select multiple attributes
Hubert Holtz wrote:
> I often visit tutorial-sites to get my informations (and now this great
> mail-list) and there was no "and", only a | for or.

"|" never really means "or".

In an XSLT pattern, which is what goes in a "match" attribute, it's just a
separator between node tests when used in a pattern. Depending on how you like 
to interpret your code into English, you might use the words "or" or "and" 
informally.

For example, <xsl:template match="foo|bar"> says this template is a good match
for a node that matches the test foo (element named foo in no namespace), and
it is also a good match for a node that matches the test bar (element named
bar in no namespace). Since a programmer might be used to reading "|" as
"or", it would be just as correct to say "this template is a good match for a
foo or a bar".

In an XPath expression, "|" is a set union operator.

In mathematics, a set is an unordered group of values, typically written (in
math, not XPath) as a comma-separated list inside curly braces: {1,2,3,4}.
Order doesn't matter. The union of two sets is the result of merging them and
eliminating duplicates. The union of {1,2,3,4} and {2,3,5} is {1,2,3,4,5}.

In XPath, it works the same way with nodes. select="foo|bar" means to use the
union of the node-set {all child::foo elements} and the node-set {all
child::bar elements}, producing the node-set.

Note that I'm mixing notations here; there are no curly braces in XPath, and
in XSLT they are only used in XSLT Attribute Value Templates to delimit XPath
expressions embedded in literal attribute values.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 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.