Subject: Re: [xsl] RE: unbelievable often asked question From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 02 Jan 2003 14:25:36 -0500 |
Cheers, Wendell
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
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] RE: unbelievable often as, Mike Brown | Thread | RE: [xsl] selecting multiple attrib, Ben Robb |
Re: [xsl] RE: unbelievable often as, Mike Brown | Date | RE: RE: [xsl] Problems with Oracle , John Pallister |
Month |