Configurable rule optimization

Highly experimental configurable optimizations can be defined through children of the patternOptimization element. Defining them requires detailed knowledge of XPath models and is not recommended at this stage for any production purposes.

The following child elements can be used to describe specific optimizations:

The canonical form of these optimization directives is:

<directive pattern="pattern" when="condition"? mode="modes"? ... .../>

where pattern is a pattern that is matched against some or all of a template match pattern (xsl:template/@match), condition is an optional predicate that can qualify expression-binding variables within the pattern and modes is a description of applicable modes, almost exactly analogous to xsl:template/@mode. The default for modes is #all; namespaced modes should be defined through EQNames.

Patterns

Patterns play a vital part in these optimization declarations, and are in part unified against template patterns. This is most easily illustrated with a simple indexation example:

<index pattern="*[tokenize(@class)=$S]" index.expr="tokenize(@class)" index.value="$S"/>

This directive is tested against template match patterns (possibly restricted to declared modes) through a form of unification. If a template is:

<xsl:template match="*[tokenize(@class) = 'Appendix']">...

then the patterns can be matched with an equivalence binding of $S := 'Appendix'. In this case this rule is deemed to be indexable: to determine the possible key for a node, the expression tokenize(@class) will be executed, resulting in a (possibly empty) sequence of strings. Similarly the rule itself will have been added to the list of rules (for this optimization) which are indexed against the string 'Appendix'.

The syntax and semantics of these patterns are in an experimental phase at present, and mostly geared to variability in and binding to string values, such as the use of $S in the example above. Currently: