xsl-list
[Top] [All Lists]

Re: The pipe '|' operator: Does it mean Or or Union?

2004-01-14 11:11:31
At 12:15 PM 1/14/2004, Jeff wrote:
kakridge(_at_)bellsouth(_dot_)net wrote:
I've noticed the the Muenchian method uses '|' and that everyone refers
to this as a Union.  However, I also read that this
<xsl:template match="foo | foobar">
means to match the foo OR foobar elements.  Does the definition of the
operator change based on the application?

Matching "foo | foobar" gives you the union of the set of all foo with the set of all foobar. You can read it as "OR", but it's still a union operator. XPath has a separate "or" operator, but that's not the same thing.

It may also help to recall the rationale for matching: my node matches a pattern if there is another node in the document from which my node can be retrieved, using the given pattern as an XPath expression. (This would make for chaos, except of course not all XPath location paths are allowed as patterns -- only some of the ones that look "down").

Since all foo and all foobar elements have parent nodes, any of them can be reached, from somewhere, using the XPath "foo | foobar". In other words, the pattern matches any node in the union set of foo and foobar elements.

(The "or" operator returns a Boolean, so it can't be used in a pattern -- apart from inside predicates -- since it doesn't return nodes at all.)

Hm, I seem to be offering lots of color commentary today....

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
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
======================================================================


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list