- Structure of the extension content
- Validation of the extension components
- Applying an extension to the instance file
Extension element
Every GS1 XML schema contains a placeholder where additional context-specific components can be inserted. The content defined in the extension schema can be added to the “core” message when the instance document is being created.
Although from technical point of view the extension can be applied to any extension point in any business document, the documentation strictly limits its use to one specific extension point in a specific message. This decision is based on the business requirement and the context which the extension will be used in.
The users decide whether to use it with the core message while creating the XML instance document. If they decide to use the extension, they must follow the usage rules specified in the BMS document.
Example
The ebMeat - Meat Item Containment Extension should be applied to the Despatch Advice line item extension point, as specified in the BMS.
Structure of the extension element
The “extension” placeholder is defined as the optional element containing the unbounded number of the XML schema '##any' elements:
Definition of the ‘extension’ element:
<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
Validation of the extension components
The XML 'any' element has a built-in attribute: ‘processContents’. It is an indicator for an application or XML processor how to handle the validation of XML documents against the elements specified by the 'any' element. In the GS1 extension component, the value of this attribute is set to 'lax', it means that the XML processor attempts to obtain the schema for the required namespaces and validate any element from those namespaces, but if the schema cannot be obtained, no errors will occur.
Although the XML syntax rules for the 'any' element allow any well-formed XML to be placed within the instance file, the users must remember that their business partners will not be able to understand the non-standard information. It is recommended to use only the extension attributes approved within the GSMP process. Otherwise the messages will not be globally interoperable. However, because the ‘processContents’ attribute is set to 'lax', the validation of the extension element is optional: an XML schema parser will validate elements for which it can find declarations (extension schemas) and raise errors if they are invalid. If it does not find context specific schemas for a certain set of context specific elements, the parser will not report errors for those elements.
Applying an extension to the instance file
In the instance file, the content of the extension should be placed within the ‘extension’ element and replace the '##any' placeholder element. The first element (root) of the extension must contain two additional attributes:
- ‘xmlns’ specifying the namespace of the extension schema
- ‘xsi:schemaLocation’ specifying the access path of the extension schema