Namespaces

An XML namespace is a collection of element types and attribute names. XML namespaces provide a way to distinguish between duplicate element types and attribute names. A duplication may occur, for example, in an XSLT stylesheet or in a document that contains element types and attributes from two different Document Type Definitions (DTDs). In an XML namespace, an element type or attribute name is uniquely identified by a two-part name property: the name of its XML namespace and its local name.

You can configure XML namespaces globally or separately for each node. An individual XML namespace configuration enables you to accomplish more advanced goals based on your requirements.

Default namespaces are supported through the overwrite Default Namespace option.

iWay Transformer also supports the mapping of multiple namespaces to the same URI and the application of a namespace prefix to a subtree.

The following example presents XML namespaces as a convenient solution to distinguish between two different XML element types named Address.

<Department>
<Name>DVS1</Name>
<addr:Address xmlns:addr="http://www.tu-darmstadt.de/ito/addresses">
<addr:Street>Wilhelminenstr. 7</addr:Street> <addr:City>Darmstadt</
addr:City> 
<addr:State>Hessen</addr:State> 
<addr:Country>Germany</addr:Country>
<addr:PostalCode>D-64285</addr:PostalCode> 
</addr:Address > 
<serv:Server xmlns:serv="http://www.tu-darmstadt.de/ito/servers"> 
<serv:Name>OurWebServer</serv:Name> <serv:Address>123.45.67.8</
serv:Address>
</serv:Server> 
</Department>

Note the first Address element type. Its name belongs to the http://www.tu-darmstadt.de/ito/addresses XML namespace. It has a universal (two-part) name of “http://www.tu-darmstadt.de/ito/addresses” and “Address”. The second element type with the same first name “Address” belongs to the http://www.tu-darmstadt.de/ito/servers XML namespace. It has a universal name of {http://www.tu-darmstadt.de/ito/servers}Address. Thus, each universal name is preserved as unique, meeting the requirement that each element type in an XML document needs to have a unique name.

You can also configure your Transform component to use XML namespaces by loading a set of namespaces from an existing Transform component. Alternatively, you can opt to create your own set. Either way, ensure that you select the Contains Namespace check box when configuring the input.

In addition, ensure that all namespaces from your input data file are described in your XML or schema structure, and that the prefixes are consistent (that is, they contain the same URI).

To better understand namespace mapping rules, you can draw the parallel between namespace mapping in iWay Transformer and long distance telephone calling using your land line.

As an example, imagine that you need to phone your aunt, who currently resides in France, from New York, USA. In order to complete the call to your aunt, your long distance calling plan must first have the country code for France on the calling plan list of permitted country codes. Otherwise, the call to France will not be completed.

In the same manner, the namespaces from the input data file can be compared to a list of country codes to be dialed. You cannot map the namespace from your input data file successfully, unless it is included in your schema or XML structure namespace list, which in this example, is similar to a long distance calling plan.

While designing projects with namespaces, check the schema and input data for consistency. Your mapping values will not appear in the output if the same namespace prefix from the incoming data has a different URI in your structure file.

The namespaces with different prefixes that have the same URI are treated as the same namespace, according to the rules outlined in XML Namespace Specifications.

For example, the following namespaces are described in your dictionary:

<a1:getMessages xmlns:a1="uri:wsdl:org.iway.sp2.customer.v1" 
xmlns:internal="uri:wsdl:org.iway.sp2.internal.v1">
.
.
.

In addition, your input data has the following namespaces:

<customer:getMessages xmlns:customer="uri:wsdl:org.iway.sp2.customer.v1" 
xmlns:internal="uri:wsdl:org.iway.sp2.internal.v1">
.
.
.

The namespaces customer and a1 are treated as the same namespace while mapping the output values.

If you are dealing with dynamic namespaces for incoming data, for which their URIs cannot be determined during design time, we recommend that you deselect the Contains Namespace check box. This will ensure that incoming data values appear in the output. For more information, see Working With Namespaces.