SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
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

# Examples of Patterns

The table below gives some examples of patterns, and explains their meaning:

Pattern | Meaning
PARA | Matches any element whose name (tag) is PARA
* | Matches any element
APPENDIX/PARA | Matches any PARA element whose parent is an APPENDIX
APPENDIX//PARA | Matches any PARA element that has an ancestor named APPENDIX
/*/SECTION | Matches any SECTION element that is an immediate child of the outermost element in the document
*[@NAME] | Matches any element with a NAME attribute
SECTION/PARA[1] | Matches any PARA element that is the first PARA child of a SECTION element
SECTION[TITLE="Contents"] | Matches any SECTION element whose first TITLE child element has the value "Contents"
A/TITLE | B/TITLE | C/TITLE | Matches any TITLE element whose parent is of type A or B or C (Note that this cannot be written "(A|B|C)/TITLE", although that is a valid XPath 2.0 path expression.)
/BOOK//* | Matches any element in a document provided the top-level element in the document is named "BOOK"
A/text() | Matches the character content of an A element
A/@* | Matches any attribute of an A element

In a schema-aware stylesheet, it can be useful to match elements by their schema-defined type, rather than by their name. The following table shows some examples of this.

Pattern | Meaning
schema-element(CHAPTER) | Matches any element that has been validated against the global element declaration named CHAPTER. More precisely, it matches an element named CHAPTER that has been validated against the type of the global element declaration named CHAPTER, and any element in the substitution group of the CHAPTER element.
element(*, ADDRESS-TYPE) | Matches any element that has been validated against the schema-defined global type definition ADDRESS-TYPE. The "*" indicates that there are no constraints on the element's name.
attribute(*, xs:date) | Matches any attribute that has been validated as an instance of xs:date, including types derived by restriction from xs:date.

Next