Introduction to Namespaces in XSLT

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Developer's Guide

Introduction to Namespaces in XSLT

A namespace defines a class (or set) of names of elements and attributes designed for use in the context of a specific technology. For example, the elements and attributes for XHTML, such as <HTML>, <BODY>, <HREF>, and so on, share the XHTML namespace. The elements defined in the XSLT Version 1.0 specification, such as <xsl:stylesheet>, <xsl:template>, <xsl:if>, and so on, share the XSLT 1.0 namespace, xsl.

A namespace is identified by a URI (for example, http://www.w3.org/1999/XSL/Transform), and by one or more namespace prefixes (for example, xsl) that serve as the short-hand of the URI. In general, an element belonging to a particular namespace is written in the format of namespace-prefix:element-name. For example, <xsl:sort>.

Namespaces help to avoid collisions of names of different classes. For example, <my:if> and <xsl:if> differentiate the <if> element of the xsl namespace from that of the my namespace.

Note   Technically, attribute names without a prefix are assumed to be in no namespace in particular. To ensure that an attribute comes from a specified namespace, use the namespace prefix when specifying the attribute.

For more information about how to associate a particular prefix with a particular namespace, see the next section, Declaring Namespaces for XSLT.