A Map object (that is, an instance of the Map class) holds a set of mappings from an XML namespace prefix to a full namespace URI. These mappings are used for resolving namespace prefixes in XML element and attribute names. See also XPath expressions, XMP location paths and the Node class in the XML module.
There is no direct constructor for Map objects. Instead the Dataset class (in the Metadata module) and the Document class (in the XML module) offer functions to obtain a new Map object. Each class offers two distinct functions:
createEmptyMap( ) returns a new empty prefix map object.
createDefaultMap( ) returns a new prefix map object that already contains all mappings that occur in the XML document associated with the receiving object
In case the script developer can easily determine the set of prefix mappings used by a script, the preferred mechanism is to add that list of prefix mappings to a newly obtained empty prefix map. In reality however this is not always practical. For example, a query expression (with prefixes) might be provided by a user at run-time and the script developer may wish to avoid exposing the complexity involving namespaces to the user.
With the default prefix map the query expression can use any of the prefixes that occur in the backing file. While this is certainly not according to the book, the conventions for the use of prefixes are often stable enough to allow this sort of convenience trick.
Adds the specified prefix to URI mapping to the map, replacing the previous mapping for this prefix if any.
Returns the URI mapped to the specified prefix or null if there is no mapping for the prefix.