Namespaces provide a method to qualify object names.
XML instance documents and XML Schemas can use namespaces.
A single XML instance document can contain elements and attributes that are defined for, and possibly used by, multiple applications. Two different elements or attributes within the same document might require the same name. Individual applications need to be able to recognize the elements and attributes that they are designed to process. In circumstances such as this, the definitions can be distinguished from each other by qualifying each element with a different namespace. This avoids problems of name collision and mistaken recognition.
XML Schemas can define a target namespace. Global elements, attributes, groups and types that are defined within an XML Schema are qualified by the target namespace, if it has been defined. Optionally, local elements and attributes can also be qualified by the target namespace. Therefore, namespaces assist in the development of a library of XML Schemas that can be developed independently. If the namespace name that is used for an XML Schema is unique, you do not have to be concerned about name clashes with objects that are defined within other XML Schemas.
The scope of a namespace extends beyond that of its containing document and is identified by a Uniform Resource Identifier (URI). In order to serve its purpose, a URI must be unique. You might be more familiar with the concept of a Universal Resource Locator (URL). URIs often use the same syntax as URLs, but the URI definition is broader than the specification of a URL. This is an example of a URI: http://mycompany.com/xml_schema
A namespace prefix is declared as a shorthand for the full URI name and this is used to qualify all elements that belong to that namespace. The prefix to be substituted for a namespace in an XML instance document or XML Schema is specified using an xmlns attribute. A default namespace can also be defined using an xmlns attribute. If a default namespace is defined, any element or attribute with no prefix is qualified with the default namespace. If no default namespace is defined, any element or attribute with no prefix is not qualified by a namespace.
A single message set which has namespaces enabled can contain a number of different namespaces. Each namespace is represented by a different Message Definition File. When you create a Message Definition File, you can choose whether it is to have an associated namespace, or whether it is be in the notarget namespace. If you choose to associate a namespace with a Message Definition File, you must also choose a prefix.
If the Message Definition File has an associated namespace, the following global objects are qualified with the namespace:
Optionally, local elements and attributes can be qualified with the namespace.
Objects that are defined within a Message Definition File can reference objects in other Message Definition Files within the same message set. To do this, import or include one Message Definition file within another Message Definition File.
If you are using XML format in the MRM domain, elements or attributes are matched, based on the namespace in the dictionary when the parsed message is matched against the dictionary that is generated from the message model. Therefore, for an element or attribute in a message to match with the dictionary, both its name and its namespace must match.
Support is provided that allows you to specify namespaces when writing ESQL or Java. It is not necessary to write ESQL or Java that is namespace aware if you are not using namespaces. However, if you decide to use namespaces, your message definition files can target any namespace that you choose, and it is necessary to write namespace-aware ESQL or Java. The namespace in which an element resides is stored in the message tree when parsed. This is a logical property and it is held regardless of the physical wire format in which messages are parsed and written. Syntax has been added to ESQL to make it easy to reference element's namespaces using defined prefixes. In Java, XPath expressions are used to reference elements.
On the World Wide Web Consortium (W3C) Web site, see: