Parsing
The XMLNS and XMLNSC parsers can
parse any well-formed XML document, whether or not the document contains
namespaces. If elements or attributes have namespaces, those namespaces
are applied to the elements and attributes in the message tree. Namespace
prefix mappings are also carried in the message tree, and are used
when serializing the message tree back to XML.
- If an element or attribute in the input XML has a namespace, the
corresponding node in the message tree also has that namespace.
- If an element contains a namespace declaration (an xmlns attribute),
a child element that contains its prefix and namespace URI is created
in the message tree.
While the message is passing through a message flow, namespaces
and namespace mappings can be modified using ESQL or any of the other
transformation technologies that are offered by message broker.
Writing
Namespaces and their prefixes are
preserved in the message tree when parsing, and are used when the
XMLNS and XMLNSC parsers convert a message tree to an XML bit stream.
- When serializing a message tree, the parser scans for namespace
declarations on each XML element. If any are found, it uses them to
select the namespace prefixes in the output document.
- If an element in the message tree has a namespace, but there is
no in-scope namespace declaration for its namespace URI, a valid namespace
prefix is automatically generated and used in the output XML. Auto-generated
prefixes have the form NS1, NS2, and so on.
Tip: If an element in the message tree has a child
element that is a ‘default namespace' declaration, every child
of that element (whether an XML element or an XML attribute, at any
nesting depth) must have a namespace. If this rule is not enforced
message broker cannot generate correct XML output for the message
tree.