Next / Previous / Contents / TCC Help System / NM Tech homepage

4.3. Namespace maps

A namespace map is a Python dictionary that relates namespace prefixes to namespaces. The dictionary's keys are the namespace prefixes and each related value is the namespace's name as an NSURI.

Namespace maps are used in several roles.

For example, at the end of Section 4.2, “The syntax of multi-namespace documents” there is an xsl:stylesheet start tag that defines xsl: as the prefix for the XSLT namespace, fo: for the XSL-FO namespace, and date: for a date-and-time extension package. Here is a namespace map that describes those same relationships of prefixes to NSURIs:

    nsm = {"xsl":  "",
           "fo":   "",
           "date": ""}

To define the NSURI of the blank namespace, use an entry whose key is None. For example, this namespace map would define elements without a namespace as belonging to XHTML, and elements with namespace prefix “xl:” belong to the XLink namespace:

    nsm = {None: "",
           "xl": ""}