Use of namespaces
This topic describes how namespaces are used in request converters and response converters.
- No validation of leaf elements. Root element can optionally be
validated (See the attribute GEN_VALIDATE_ROOT_IN_NS in CodegenProperty),
AND
- No distinction can be made for elements that only differ by namespace (For example, elements "q:a" and "q1:a" where q and q1 are bound to different namespaces in the message are treated as just "a")
For the response conversion (COBOL to XML) the correct qualification prefixes and namespaces are generated based on the schema(s) for the XML message.
For optimization purposes, if all the elements of the response message are bound to the same namespace they are implicitly qualified using a default namespace. For example, the response converter generates the message shown in Figure 1.
<?xml version="1.0" encoding="UTF-8"?>
<LONEPost xmlns="http://www.loneI.com/schemas/loneIInterface"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loneI.com/schemas/loneIInterface LONEI.xsd ">
<Company>IBM</Company>
<Voucher_number>002</Voucher_number>
<Transaction_type>001</Transaction_type>
<Delivery_system>POST</Delivery_system>
<Transfer_date>16002007</Transfer_date>
<Posting_date>17152007</Posting_date>
</LONEPost>
Instead of the message shown in Figure 2.
<?xml version="1.0" encoding="UTF-8"?>
<cbl:LONEPost xmlns:cbl="http://www.loneI.com/schemas/loneIInterface"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loneI.com/schemas/loneIInterface LONEI.xsd ">
<cbl:Company>IBM</cbl:Company>
<cbl:Voucher_number>002</cbl:Voucher_number>
<cbl:Transaction_type>001</cbl:Transaction_type>
<cbl:Delivery_system>POST</cbl:Delivery_system>
<cbl:Transfer_date>16002007</cbl:Transfer_date>
<cbl:Posting_date>17152007</cbl:Posting_date>
</cbl:LONEPost
The response XML converter uses this optimization when possible to reduce the size of XML messages, this optimization has conservation benefits from CPU time to network bandwidth.
Figure 3 is an example of an XML Schema with mixed elementForm values:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:addr="http://www.address.com/"
targetNamespace="http://www.address.com/"
elementFormDefault="unqualified" attributeFormDefault="unqualified">
<complexType name="USAddress">
<sequence>
<!-- explcit Form="qualified" -->
<element name="name" type="string" form="qualified"/>
<!-- implicit Form="unqualified" -->
<element name="street" type="string"/>
</sequence>
</complexType>
</schema>
For the schemas with mixed element qualification, the response converter generates the namespaces prefixes when required. For the previous schema with mixed element qualification (see Figure 3), the response converter generates a message containing the following fragment:
...
<addr:name>addr:name</addr:name> <!-- qualified -->
<street>street</street> <!--unqualified-->
...