Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - template match or is | what is and? [Thread Next] Re: template match or is | what is and?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...... > > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
