Skip to main content

What is a namespace in XML?

A namespace is a method to prevent element name conflicts in XML.

What is a namespace in XML used for?

In XML, element names are defined by the developer. This sometimes results in a conflict when mixing XML documents with different XML applications. In XML schemas, the namespace is used to distinguish different template libraries from each other.

How does a namespace work in XML?

Name conflicts in XML can be avoided by distinguishing the different libraries by adding a prefix. We call this prefix a namespace in XML documents. This namespace can also be used to distinguish different types of messages (order, packing slip, etc.).

Looking up information in a namespace

In its basis, the namespace is not intended to look up information. However, companies often use the namespace as a pointer to a library with underlying information.

What is a library?

A library is a scheme with common elements and works in the following way: you have an order, order response, packing slip and invoice. All these messages have elements in which the customer code (at Onetrail a GLN) and address data are listed. Without namespace you have to redefine these elements per message. By including a schema with a namespace in the XML document, you can use it in all messages. The schema with the common elements, the library, can then be included in XML documents by means of an include.

How does Onetrail use namespaces in XML?

Namespaces in XML are often considered difficult and cumbersome. At Onetrail, we have a different opinion. We mainly see the advantages of the namespace, which serve as a powerful tool to keep our message traffic on the right track. Onetrail gladly helps you to apply namespaces in your process.

Example of a namespace in XML

A good example is the UBL message set. There are different values with regard to amounts between the standard UBL and the Dutch taxonomy version. Here, the different versions are distinguished with the help of the namespace.