XML namespace issues - 8.0

Talend Data Mapper User Guide

Version
8.0
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2024-02-29

A frequent problem when using namespaces is the XML element(s) are not read because their namespace does not match the expected namespace. This can result in no output when you are running a map, especially if this is true of the root element of the XML instance document. Generally if you are using structures created by importing XML Schema/WSDL you should not have troubles if the XML instance documents have the correct corresponding namespaces.

If you add elements manually or create a structure manually it is important to carefully check that your namespace definitions in the structure and namespace container are correct.

Here are some things to check:
  • Default Namespace - Often an XML document will use a default namespace, so the elements are not marked with a prefix, but there is an xmlns attribute that defines the namespace. If this is the case make sure the elements in the structure definition are using the same namespace. To do this, check the following points.

  • XML Representation (Namespace Container) - Does the XML representation of the structure pointed to by the map input contain a reference to a namespace container? This can be determined by finding the XML representation of the structure and viewing its properties (double clicking on it). If not, create a namespace container if necessary and point the representation to it.

  • Namespace Container - Is the default (or other) namespace defined in the namespace container associated with the map's input structure? If not, add it with the appropriate prefix. If it's the default namespace then you can just use the prefix default. Also, for the default namespace you should change the properties of the namespace container (right click -> Properties) to specify the default namespace URI. When you specify a namespace URI as the default URI, the prefixes associated with that namespace do not appear in the structure or map editors.

  • Element's Namespace - Each element can have a namespace associated with it. This is done exactly like an XML document using a namespace prefix. So for example if your default namespace URI is urn:default and the prefix is default edit the element (called elementName for example) in the stucture editor and change it's name to default:elementName. You will see in the element's properties (the right side of the structure editor) that the element now has a namespace URI (use the read only view of the element's properties to see this).