KindTests and NodeTests

The syntax for the element() and attribute() KindTests is extended to allow constructs of the form

element(*:div)

or

attribute(myns:*, myns:someType)

More specifically, the grammar for ElementNameOrWildCard changes from ElementName | "*" to simply NameTest; and similarly AttribNameOrWildCard also expands simply to NameTest. This change is made largely for orthogonality reasons (there is no reason to have different rules for the two constructs) and also because it provides some useful extra functionality: for example in XSLT it is now possible to match all elements in a particular namespace having a particular type with a template rule that specifies match="element(my:*, my:type)".

The default priority for an XSLT pattern in the form element(X) is always the same as the default priority for X, so for example the default priority of element(my:*) is -0.25. If a type is present, then we follow the principle that the default priority of element(my:*, T) is midway between the priorities of element(*, T) and element(E, T): that is, 0.125.

From Saxon 12, NodeTests used in steps are extended to allow, for example, ancestor::(section|appendix). This will select all ancestors named section or appendix. The meaning is similar to ancestor::section|ancestor::appendix, except when a numeric predicate is used: because ancestor is a reverse axis, ancestor::(section|appendix)[1] selects the innermost ancestor that satisfies the node test. As well as simple names, the options used within the parentheses can include kind tests (such as comment() and text()) and wild cards (such as *:code and ns:*). There must be an explicit axis, but @ can be used as an abbreviation for attribute::. For example, @(name, id) selects the name and id axes.

In match patterns, union node tests work like union patterns, so match="@(code, ns:*)" is equivalent to having two separate template rules, matching the two node tests, with different default priority.