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

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

This means that even these attributes (which are unusual because their names are in the target namespace of the schema) are not declared globally and therefore not available for use in sequence type descriptors. It would be possible to change the schema to the following form (selecting just three of the attributes for brevity):





   

   

   


and you could then use
schema-attribute(xsl:version)
as a sequence type descriptor.

Much more common, I think, is to use the form
attribute(*,
T)
which matches attributes that have a particular type annotation. For example, many attributes in XSLT have the type
xsl:QName
. An example is the
name
attribute of

, allowing you to write, for example,

. This type is a variant of the built-in type
xs:QName
. It has the same lexical form as an
xs:QName
but is not derived from it because the validation rules are subtly different: in XML Schema, an
xs:QName
with no prefix is assumed to be in the default namespace, but in XSLT, an
xsl:QName
with no prefix is assumed to be in no namespace.

If you wanted to write a stylesheet to process all the attributes of type
xsl:QName
, perhaps to standardize the namespace prefixes that are used, you could define an XSLT template rule of the form:


 …


There is no way of writing a sequence type descriptor that matches a local element or attribute definition in a schema. In many cases local element and attributes in a schema are defined by reference to a global type, and in this case you can use the syntax
element(E,
T)
or
attribute(A,
T)
. With this syntax, the name
E
or
A
can be any element or attribute name you choose; it doesn't have to be the name of a global element or attribute defined in the schema.

We've now finished our survey of the
SequenceType
syntax, and the next two sections describe the two XPath constructs (
instance of
and
treat as
) in which this syntax is used.

Other books

The Twelve Kingdoms by Jeffe Kennedy
Yesterday's Magic by Beverly Long
Laid Open by Lauren Dane
Lady Love by Diana Palmer
Boss Me by Lacey Black
A Tragic Wreck by T.K. Leigh
Carolina Heart by Virginia Kantra
The Child Bride by Cathy Glass