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

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

If the element includes the attribute
xsi:nil = “true”
, then it will match this
KindTest
only if the
QName
is followed by the symbol
?
. This extra test is necessary because without it, the system would not be able to make any assumptions about the contents of the element, since
xsi:nil
essentially allows an element to have no content even when the schema would otherwise require it.

  • The KindTest
    element(QName, QName)
    tests both the name of the node and its type: the name must match the first
    QName
    , or the name of one of the elements in its substitution group, and the type annotation must match the second
    QName
    (which must be the name of a top-level type definition in an imported schema). Again, if the element includes the attribute
    xsi:nil = “true”
    , then it will match this
    KindTest
    only if the second
    QName
    is followed by the symbol
    ?
    .

KindTests for Attribute Nodes

KindTests
for attribute nodes follow the same format as those for element nodes, with minor variations. The same options are available, though in practice they are likely to be used rather differently. In particular, global attribute declarations are not used very often in XML Schema, and matching against the names of a top-level simple type definition is probably a more likely scenario.

  • attribute(QName)
    matches any attribute whose name matches the given
    QName
    : as a pattern, this means exactly the same as
    @QName
    or
    attribute::QName
    .
  • schema-attribute(QName)
    is used to test for an attribute that matches a top-level attribute declaration in the schema identified by the given
    QName
    . It's an error to use this form unless you have imported a schema containing this top-level attribute declaration. The attribute is considered to match if two conditions are satisfied:
    • Its name is the same as the QName.
    • The type of the attribute node, identified from its type annotation, matches the type defined for this attribute declaration in the schema.
  • attribute(*, QName)
    is used to test for an attribute whose type annotation indicates that it has been successfully validated against the schema-defined simple type definition identified by the
    QName
    . The
    QName
    can identify a built-in type such as
    xs:dateTime
    , or a type (it will always be a simple type) that is the subject of a named type definition in an imported schema. The test will match any attribute that has a type annotation that refers to the named type, or a type derived from the named type by restriction. For example, the
    KindTest
    attribute(*, xs:date)
    matches any attribute whose type (as established by schema validation) is
    xs:date
    .
  • The
    KindTest
    attribute(QName, QName)
    is essentially a combination of
    attribute(QName)
    and
    attribute(*, QName)
    . This tests both the name of the node and its type: the name must match the first QName, and the type annotation must match the second QName (which must be the name of a top-level simple type definition in an imported schema).
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
4.77Mb size Format: txt, pdf, ePub
ads

Other books

P I Honeytrap by Baird, Kristal
The Four Realms by Adrian Faulkner
Surprise Package by Henke, Shirl
Time of Attack by Marc Cameron
Inferno Anthology by Gow, Kailin, Keeland, Vi, Knight, Kimberly, Leo, Cassia, Moore, Addison, Morris, Liv, Paige, Laurelin, Romig, Aleatha, Sorensen, Jessica, Weatherford, Lacey
Maybe Baby Lite by Andrea Smith
Keyboards and Kink by Danica Avet, Sandra Bunio, Vanessa Devereaux, Carolyn Rosewood, Melissa Hosack, Raven McAllan, Kassanna, Annalynne Russo, Ashlynn Monroe, Casey Moss, Xandra James, Jorja Lovett, Eve Meridian