XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition

Free XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay

Book: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay Read Free Book Online
Authors: Michael Kay
using a method such as selectNodes(XPath) , and this feature is now included in the current version of the standard, DOM3. Subsets of XPath are used within the XML Schema language and in XForms for defining validation conditions, and bindings of XPath to other languages such as Perl are multiplying. Perhaps most important of all, the designers of XQuery decided to make their language a pure superset of XPath. The language has also proved interesting to academics, and a number of papers have been published analyzing its semantics, which provides the basis for optimized implementations.
    XSLT and XML Namespaces
    XSLT is designed on the basis that XML namespaces are an essential part of the XML standard. So when the XSLT standard refers to an XML document, it always means an XML document that conforms to the XML Namespaces specification, which can be found at http://www.w3.org/TR/REC-xml-names .
    Namespaces play an important role in XSLT. Their purpose is to allow you to mix tags from two different vocabularies in the same XML document. We've already seen how a stylesheet can mix elements from the target vocabulary (for example HTML or XSL-FO) with elements that act as XSLT instructions. Here's a quick reminder of how namespaces work:
Namespaces are identified by a Uniform Resource Identifier (URI). This can take a number of forms. One form is the familiar URL, for example http://www.wrox.com/namespace . Another form, not fully standardized but being used in some XML vocabularies, is a URN, for example urn:biztalk-org:biztalk:biztalk_1 . The detailed form of the URI doesn't matter, but it is a good idea to choose one that will be unique. One good way of achieving this is to use the domain name of your own website. But don't let this confuse you into thinking that there must be something on the website for the URI to point to. The namespace URI is simply a string that you have chosen to be different from other people's namespace URIs; it doesn't need to point to anything.
The latest version, XML Namespaces 1.1, allows you to use an International Resource Identifier (IRI) rather than a URI. The main difference is that this permits characters from any alphabet (for example, Chinese); it is no longer confined to ASCII. In practice, most XML parsers have always allowed you to use any characters you like in a namespace URI.
Since namespace URIs are often rather long and use special characters such as / , they are not used in full as part of the element and attribute names. Instead, each namespace used in a document can be given a short nickname, and this nickname is used as a prefix of the element and attribute names. It doesn't matter what prefix you choose, because the real name of the element or attribute is determined only by its namespace URI and its local name (the part of the name after the prefix). For example, all my examples use the prefix xsl to refer to the namespace URI http://www.w3.org/1999/XSL/Transform , but you could equally well use the prefix xslt , so long as you use it consistently.
For element names, you can also declare a default namespace URI, which is to be associated with unprefixed element names. The default namespace URI, however, does not apply to unprefixed attribute names.
    A namespace prefix is declared using a special pseudo-attribute within any element start tag, with the form:
    xmlns:prefix = “namespace-URI”
    This declares a namespace prefix, which can be used for the name of that element, for its attributes, and for any element or attribute name contained in that element. The default namespace, which is used for elements having no prefix (but not for attributes), is similarly declared using a pseudo-attribute:
    xmlns = “namespace-URI”
    XML Namespaces 1.1 became a Recommendation on February 4, 2004, and the XSLT 2.0 specification makes provision for XSLT processors to work with this version, though it isn't required. Apart from the largely cosmetic change from URIs to IRIs mentioned

Similar Books

All or Nothing

Belladonna Bordeaux

Surgeon at Arms

Richard Gordon

A Change of Fortune

Sandra Heath

Witness to a Trial

John Grisham

The One Thing

Marci Lyn Curtis

Y: A Novel

Marjorie Celona

Leap

Jodi Lundgren

Shark Girl

Kelly Bingham