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

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

A
NameTest
of the form
*:code
matches any node whose local-name is
code
, regardless of its namespace (it will match names in any namespace, as well as names that are in no namespace).

The
NameTest
xyz:code
matches any name whose namespace is the one currently bound to the namespace prefix
xyz
and whose local part is
code
. Again, the name being tested doesn't need to use the same prefix, provided it refers to the same namespace URI.

The interpretation of a
NameTest
such as
code
(with no namespace prefix) depends on the context:

  • If it is used with any axis other than the attribute or namespace axes, then it selects elements whose name is in the namespace identified in the XPath context (see Chapter 7) as the default namespace for element and type names. In XSLT, this is established using the
    [xsl:]xpath-default-namespace
    attribute, typically on the

    element. It is not affected by a default namespace declaration of the form
    xmlns=“some.uri”
    .
  • If it is used with the attribute or namespace axis, then it selects nodes whose namespace URI is null.

If your source document uses a default namespace declaration such as
xmlns = “some.uri”
, then a

element in the source document will not be selected by an XPath expression such as
//code
, even if the stylesheet contains the same namespace declaration
xmlns=“some.uri”
. This is because in the XPath expression, the default namespace is ignored. You will either need to specify an explicit namespace declaration such as
xmlns:x=“some.uri”
and refer to the element as
//x:item
, or to declare an
xpath-default-namespace
in the stylesheet.

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

Other books

Voice of Crow by Jeri Smith-Ready
Young Squatters by London, Blair
Evaleigh by Stark, Alexia
Homeless by Laurie Halse Anderson
Elevator, The by Hunt, Angela
Hive Invasion by James Axler