Rational Developer for System z

Use of namespaces

This topic describes how namespaces are used in request converters and response converters.

For the request conversion (XML to COBOL) only the target namespace of the root element is recognized by the converter. Target namespaces can be assigned by prefixing an element with a namespace prefix (forming a QName) or declaring a default namespace. The following restrictions apply:

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.

Figure 1. Example of Response Converter Message Using Implicitly Qualified Elements
<?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.

Figure 2. Example of Response Converter Message Using Explicitly Qualified Elements
<?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
Note: The content of Figure 1 and Figure 2 is equivalent; however Figure 1 is a more efficient use of XML Namespaces.

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.

Note: This optimization is only possible if the elementForm values (explicit or implicit) are the same for all mapped items.

Figure 3 is an example of an XML Schema with mixed elementForm values:

Figure 3. Example of 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-->
...

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)