SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
| Introduction
| xsl:analyze-string
| xsl:apply-imports
| xsl:apply-templates
| xsl:attribute
| xsl:attribute-set
| xsl:call-template
| xsl:character-map
| xsl:choose
| xsl:comment
| xsl:copy
| xsl:copy-of
| xsl:decimal-format
| xsl:document
| xsl:element
| xsl:fallback
| xsl:for-each
| xsl:for-each-group
| xsl:function
| xsl:if
| xsl:include
| xsl:import
| xsl:import-schema
| xsl:key
| xsl:matching-substring
| xsl:message
| xsl:namespace
| xsl:namespace-alias
| xsl:next-match
| xsl:non-matching-substring
| xsl:number
| xsl:otherwise
| xsl:output
| xsl:output-character
| xsl:param
| xsl:perform-sort
| xsl:preserve-space
| xsl:processing-instruction
| xsl:result-document
| xsl:sequence
| xsl:sort
| xsl:strip-space
| xsl:stylesheet
| xsl:template
| xsl:text
| xsl:value-of
| xsl:variable
| xsl:when
| xsl:with-param
| Literal Result Elements
» | XSLT Patterns
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# Pattern syntax

Saxon supports the full XSLT syntax for patterns. The rules below describe a simplified form of this syntax (for example, it omits the legal but useless pattern '@comment()'):

    pattern          ::= path ( '|' path )*
    path             ::= anchor? remainder? (Note 1)

    anchor           ::= '/' | '//' | id | key
    id               ::= 'id' '(' value ')'
    key              ::= 'key' '(' literal ',' value ')'
    value            ::= literal | variable-reference

    remainder        ::= path-part ( sep path-part )*
    sep              ::= '/' | '//'
    path-part        ::= node-match predicate+
    node-match       ::= kind-match | type-match
    kind-match       ::= element-match |
                         text-match |
    					 attribute-match |
    					 pi-match |
    					 any-node-match
    element-match    ::= 'child::'? ( name | '*' )
    text-match       ::= 'text' '(' ')'
    attribute-match  ::= ('attribute::' | '@') ( name | '*' )
    pi-match         ::= 'processing-instruction' '(' literal? ')'
    any-node-match   ::= 'node' '(' ')'

    type-match       ::= ('element'|'attribute')
                            '(' ('*'|node-name) (',' type-name) ')'

    predicate        ::= '[' ( boolean-expression |
                               numeric-expression ) ']'

Note 1: not all combinations are allowed. If the anchor is '//' then the remainder is mandatory.

The form of a literal is as defined in expressions; and a predicate is itself a boolean or numeric expression. As with predicates in expressions, a numeric predicate [P] is shorthand for the boolean predicate [position()=P].

Informally, a pattern consists of either a single path or a sequence of paths separated by vertical bars. An element matches the match-pattern if it matches any one of the paths.

A path consists of a sequence of path-parts separated by either "/" or "//". There is an optional separator ("/" or "//") at the start; a "//" has no effect and can be ignored. The last path-part may be an element-match, a text-match, an attribute-match, a pi-match, or a node-match; in practice, a path-part other than the last should be an element-match.

The axis syntax child:: and attribute:: may also be used in patterns, as described in the XSLT specification.