GS1 namespace structure
The namespaces in GS1 reflect the domain, the interchange which the schema is used in and the major version of the schema release. The GS1 namespaces have the format of the Uniform Resource Names (URN). All URNs have the following structure:
<URN>= "urn:" <NID> ":" <NSS>
where:
<NID> is the Namespace Identifier
<NSS> is the Namespace Specific String
In all the GS1 namespaces, “gs1” is used for the NID. The NSS of all URNs assigned by GS1 have the following hierarchical structure:
urn:gs1:<domain>:<interchange>:<type>:<version-id>
where:
- domain – GS1 Business Area, Service, Technology, e.g. GS1 EDI
- interchange – Artefact within the GS1 Domain, e.g. Order
- type – Resource type, e.g. xsd
- version-id – Version of the Interchange, e.g. 3
Examples:
- urn:gs1:ecom:ecom_common:xsd:3 - the GS1 namespace for eCom common library
- urn:gs1:shared:shared_common:xsd:3 - the GS1 namespace for shared common library
- urn:gs1:ecom:order:xsd:3 - the GS1 namespace for GS1 EDI Order
Note: NSS in GS1 namespaces is case-sensitive, even though in the RFC 2141 is specified as not sensitive.
GS1 namespace prefix
GS1 XML schemas do not use any default namespace. The prefix should be explicitly specified for each namespace. The GS1 standard specifies the standard namespace prefixes that are created from the name of the schema file.
Examples:
- "order" for Order.xsd:
order="urn:gs1:ecom:order:xsd:3"
- "invoice" for Invoice.xsd:
invoice="urn:gs1:ecom:invoice:xsd:3"
- "despatch_advice" for DespatchAdvice.xsd:
despatch_advice="urn:gs1:ecom:despatch_advice:xsd:3"
- "ecom_common" for EcomCommon.xsd:
ecom_common="urn:gs1:ecom:ecom_common:xsd:3"
- "shared_common" for SharedCommon.xsd:
shared_common="urn:gs1:shared_common:xsd:3"
For the sake of consistency and interoperability in GS1 System it is recommended that for the XML instance documents the implementers use the same namespace prefixes as those used in the standard GS1 XML Schemas.
Although, from the XML syntax point of view, any prefix can be used as long as it points to the correct namespace, assigning non-standard prefixes would compromise the global interoperability of standards.
In addition, certain mapping and processing XML tools are prefix sensitive and use of non-matching prefixes by the business partners causes serious validation and processing problems.
XML schema namespace and prefix
For the XML schema components, the World Wide Web Consortium (W3C) URL http://www.w3.org/2001/XMLSchema is used as the namespace. Again, the prefix for that namespace has been standardised in the GS1 System and all the existing schema modules use xsd: for the XML Schema namespace.
Qualifying of GS1 XML schema components
In the GS1 XML schemas the values of the <xsd:schema> “form” attributes are set to “unqualified” both for ‘elementFormDefault’ and ‘attributeFormDefault’. Thus, the namespace prefixes are not exposed in the instance files, except for the root element of the business message and extension – if used.
The SBDH schemas, however, set the value of the ‘elementFormDefault’ to “qualified” and ‘attributeFormDefault’ to “unqualified”. Thus, all the SBDH elements need to start with the namespace prefix: ‘sh:’.
Example:
- GS1 XML schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" attributeFormDefault="unqualified">
- GS1 XML instance:
<order:orderMessage xmlns:order="urn:gs1:ecom:order:xsd:3" xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:gs1:ecom:order:xsd:3 ../Schemas/gs1/ecom/Order.xsd">
<sh:StandardBusinessDocumentHeader>
<!—SBDH CONTENT-->
</sh:StandardBusinessDocumentHeader>
<order>
<!—ORDER DOCUMENT CONTENT-->
</order>
</order:orderMessage>
GS1 namespace use
In GS1 XML 3.0 every schema document has a separate namespace. The namespace are no longer shared between multiple schema files. Thus, when re-using the schema artefacts defined in another schema file, the <xsd:import> element is used.