XML namespace processing

Namespaces allow the use of multiple XML schemas definitions within an XML document or building a grammar from several different schemas, by providing a way to resolve name conflicts between the schemas. For example, one schema may define a "address" element to be a mailing address that includes street, city, state, and zip code elements. Another may define "address" to be an e-mail address that contains a simple string. By using different namespaces, these can be uniquely identified.

For example, to show that the element "address" belongs to a particular namespace, a schema or instance document defines a prefix for the namespace. For instance, it might define xmlns:po="http://example.com/ns/POExample". Then when the qualified element appears in the data, the element appears as <po:address>, to show that it is part of that namespace. The "po" prefix in this example is just a shorthand way to represent the namespace "http://example.com/ns/POExample". Even though the schema might use prefix "po", instance documents may use different prefixes, for example "mypo", "purch", or it may even define it as the default namespace, so no prefix is used for this element. As long as these were defined to the "http://example.com/ns/POExample" namespace in the instance documents, they should all be considered equivalent.

The mapping and translation for XML schemas is namespace-aware. This means that it recognizes that the prefix represents a namespace, and gives it special treatment instead of just treating it as part of the element name. Since the schema translation and mapping is namespace-aware, elements with the same name and namespace would be considered to be equivalent, even if they used different prefixes.

When a schema is imported, the schema is scanned for any "xmlns" attributes. If an "xmlns" attribute is found for a namespace that is not already represented by a Namespace object in the XML Dictionary, a new Namespace object is created using the prefix defined for the attribute.

Namespace Processing for Input XML documents

You must indicate in the WebSphere Partner Gateway Console that namespace processing is to be performed if you are doing schema validation or your XML schema uses namespace qualified elements or attributes. Namespace processing is required for schema validation because the attributes that help locate the schema definitions ("xsi:schemaLocation" and "xsi:noNamespaceSchemaLocation") use namespace qualification. If your source or target document is a schema that uses qualified elements or attributes, namespace processing is required so the internal names used by the translation process will match the internal names used in the map.

Namespace Processing for Output XML Documents

When generating output XML documents, qualified elements and attributes use the prefix specified by the namespace table entry for the URI. If no prefix is specified, or if no namespace entry exists for a namespace URI, then the element or attribute is written without a prefix (i.e., using the default namespace).

Some special attributes are sometimes needed in the XML output to identify the namespaces used and the schema location. Several mapping commands exist to specify these.

Refer to each of the following commands in the Data Interchange Services online help for additional information:

Copyright IBM Corp. 2003, 2005