This topic provides information specific to dealing with messages that belong to the XMLNS domain, and that are parsed by the generic XML parser. The XMLNS domain is an extension of the XML domain and provides namespace support. Follow the guidance provided for XML messages in Manipulating messages in the XML domain, in conjunction with the information in the topic Manipulating message body content.
The following example shows how to use ESQL to work with namespaces. The example declares namespace constants at the start of the main module so that you can use prefixes in the ESQL statements instead of the full namespace URIs.
The namespace constants affect only the ESQL; they do not control the prefixes generated in the output message. The prefixes in the generated output message are controlled by namespace declarations. You can include namespace declarations in the tree using the XML.NamespaceDecl correlation name. These elements are then used to generate namespace declarations in the output message.
If, when the output message is generated, the namespace with which an element or attribute is qualified has no corresponding namespace declaration, one is automatically generated using prefixes of the form NSn where n is a positive integer.
CREATE COMPUTE MODULE xmlns_doc_flow_Compute CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN CALL CopyMessageHeaders(); -- Declaration of namespace constants DECLARE sp1 NAMESPACE 'http://www.ibm.com/space1'; DECLARE sp2 NAMESPACE 'http://www.ibm.com/space2'; DECLARE sp3 NAMESPACE 'http://www.ibm.com/space3'; -- Namespace declaration to associate prefix 'space1' with the namespace SET OutputRoot.XMLNS.message.(XML.NamespaceDecl)xmlns:space1 = 'http://www.ibm.com/space1'; SET OutputRoot.XMLNS.message.sp1:data1 = 'Hello!'; -- Default Namespace declaration SET OutputRoot.XMLNS.message.sp2:data2.(XML.NamespaceDecl)xmlns = 'http://www.ibm.com/space2'; SET OutputRoot.XMLNS.message.sp2:data2.sp2:subData1 = 'Hola!'; SET OutputRoot.XMLNS.message.sp2:data2.sp2:subData2 = 'Guten Tag!'; SET OutputRoot.XMLNS.message.sp3:data3 = 'Bonjour!'; SET OutputRoot.Properties.MessageDomain = 'XMLNS'; RETURN TRUE; END; CREATE PROCEDURE CopyMessageHeaders() BEGIN DECLARE I INTEGER 1; DECLARE J INTEGER CARDINALITY(InputRoot.*[]); WHILE I < J DO SET OutputRoot.*[I] = InputRoot.*[I]; SET I = I + 1; END WHILE; END; END MODULE;
<message xmlns:space1="http://www.ibm.com/space1"> <space1:data1>Hello!</space1:data1> <data2 xmlns="http://www.ibm.com/space2"> <subData1>Hola!</subData1> <subData2>Guten Tag!</subData2> </data2> <NS1:data3 xmlns:NS1="http://www.ibm.com/space3">Bonjour!</NS1:data3> </message>
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ac17330_ |