Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: template match or is | what is and?

From: "Marrow" <m--a-r-r-o-w@--------------------.--->
To: NULL
Date: 10/1/2004 1:42:00 AM
Hi Daniel,

> in template match if | is or then how do you do and? also, can you nest
> and/or logic w/ some sort of paranthesis or something?

'|' is the union operator - it isn't strictly logical-or... only in match
patterns can you imagine the '|' union operator to be synonymous with the a
logical-or (actually described in the specs as 'alternatives').  In XPath
syntax logical-or is represented by the token 'or' - and so, logically ;),
logical-and is represented by the token 'and'.

However, bear in mind that although match patterns share much the same
syntax as XPath expressions - they are not exactly the same thing.  (It is a
happy, by design coincidence that match patterns use a similar syntax to
XPath - see http://www.w3.org/TR/xslt#patterns where they specifically refer
to match patterns as having their own specific grammar).  So, while it is
true that any match pattern will be a valid XPath expression - it is not
true that any valid XPath expression is a valid match pattern.

e.g., while...
  <xsl:value-of select="a or b"/>
is perfectly valid - the match pattern...
  <xsl:template match="a or b">
is invalid.
Also, while...
  <xsl:value-of select="(a) | (b)"/>
is perfectly valid - the match pattern...
  <xsl:template match="(a) | (b)">
is invalid.
(Oh, and seeing as this is a MS ng - pls don't test the second example using
MSXML3 and tell me it is valid after all... it isn't... it's just that
MSXML3 allows some sloppy stuff).


So if you do wish to imagine match patterns as XPath expressions (which
really isn't advisable) - then you need to consider them as expressions that
must evaluate to a node set (or even just a node).
Therefore, a few notable differences between XPath expressions and match
patterns that are relevant to your question...
* boolean operators ('and', 'or' and 'not') may only be used within
predicates [] in a match pattern;
* grouping/order precedence parenthesis () can also only be used within
predicates [] in a match pattern
(there's a few more too!)

But then, i'd have to ask why anyone would want to use logical-and in a
match pattern (outside of a predicate)?  For example, if it were valid
(which it isn't) - what would...
  <xsl:template match="a and b">
mean?  would it mean that the node pushed out and to be caught by this
template must be both an <a> and a <b> element at the same time - which it
couldn't be?  Perhaps the answer to your question depends on what you are
actually trying to accomplish with your match pattern.

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator


"Daniel" <softwareengineer98037@y...> wrote in message
news:eLAIyU0pEHA.3668@T......
>
>




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent