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
12.48Mb size Format: txt, pdf, ePub
ads

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.

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

Other books

Looking for Laura by Judith Arnold
Crows by Charles Dickinson
Under the Bridge by Rebecca Godfrey, Ellen R. Sasahara, Felicity Don
The Phoenix Project by Kris Powers
Spiral by Paul Mceuen
Love Country (BWWM Romance) by Destiny Lewis, BWWM Crew
Statistic by Dawn Robertson
Tomb of the Golden Bird by Elizabeth Peters
Outlaw by Lowell, Elizabeth
Silent Night by Natasha Preston