On Monday, 24 January 2011 at 6:36PM, Michael Kay wrote:
On 24/01/2011 17:06, HILLMAN, Tomos wrote:Hi; just a quick query for my own understanding. Apologies if I've gotten the wrong list.
I wanted to use both a union and operator in an XLST template, i.e. match="(div1|div2)[not(@role)]" (simplified).
This is, I think, equivalent in XPath 2.0 as "/*//(div1|div2)[not(@role)]", which I would expect to follow the rule for patterns in XSLT (the node $N matches pattern PAT if $N is a member of expression "root($N)//(PAT)". However, this shows as invalid.
Can someone explain this to me? :)
One of the reasons for the restriction that "|" is allowed only as the
top-level operator in an XSLT pattern is that it affects the algorithm
for computing the default priority of the template rule.
You can write this pattern as
div1[not(@role)] | div2[not(@role)]
or as
*[not(@role)][self::div1 or self::div2]
(In Saxon, the first version will perform better).
Michael Kay
Saxonica
_______________________________________________________________________
XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.
[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php