XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (252 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
10.61Mb size Format: txt, pdf, ePub

The name Attribute

The
name
attribute is a lexical
QName
; that is, a name optionally qualified with a namespace prefix. If there is a prefix, it must correspond to a namespace declaration that is in scope on this element (which means it must be defined either on this element itself or on the

element). If there is no prefix, the namespace URI is null; the default namespace is not used.

This name is used when the template is invoked using

. The
name
attribute of the

element must match the
name
attribute of the

element. Two names match if they have the same local part and the same namespace URI, but the prefix can be different.

If there is more than one named template in the stylesheet with the same name, the one with higher import precedence is used; for details, see

on page 359. It is an error to have two templates in the stylesheet with the same name and the same import precedence, unless there is another one with the same name and a higher import precedence. This is an error even if the template is never called.

The priority Attribute

The
priority
attribute is a number, for example
17
,
0.5
, or
-3
: more specifically, an
xs:decimal
as defined in XML Schema, which allows an optional leading sign.

The
priority
attribute is used to decide which template to invoke when

is called and there are several possible candidates. For each node selected by the

instruction, a template rule is chosen using the following procedure:

  • First select all the templates that have a
    match
    attribute.
  • From these, select all the templates that match the mode that is used on the call of

    . An

    instruction uses either a specific mode (identified by a
    QName
    ) or the default mode (which is unnamed) or it can specify
    #current
    , in which case it uses whatever mode is the current mode at the time. An

    element can specify a list of modes that it matches (which can include
    #default
    to indicate that it matches the default mode), or it can specify
    #all
    to indicate that it matches all modes; if it has no
    mode
    attribute, then it matches only the default mode.
  • From these, select all those whose pattern matches the selected node.
  • If there is more than one, select those that have the highest import precedence.
  • If there is still more than one, select those that have the numerically highest priority.

Other books

A Corpse in a Teacup by Cassie Page
Plotting at the PTA by Laura Alden
Love Is the Best Medicine by Dr. Nick Trout
NS by u
Valley So Low by Patrice Wayne
The Earl Who Loved Me by Bethany Sefchick
American Fun by John Beckman
Shrinking Ralph Perfect by Chris d'Lacey