XML schema design model
GS1 uses the schema design model commonly referred to as Venetian Blind, where all the types are defined globally (nested only in the <xsd:schema> element) and all the elements and attributes are defined locally, within the type definitions.
XML built-in types
The XML standard developed by the World Wide Web Consortium (W3C) lists 44 data types that are defined in the specification. This means that these data types can be used in XML schemas with no need to define them. These data types should be implicitly understood by all the XML aware software tools. The built-in data types have certain standard facets to represent them in the schema or to restrict their range.
The following W3C data types ARE USED in GS1 standards:
|
|
|
The following W3C data types ARE NOT USED in GS1 standards:
|
|
|
‘xsd:string’ Pattern facet
The pattern (also referred to as regular expression) is one of the facets restricting the <xsd:string> built-in type. Patterns are used in GS1 XML schemas to define the GS1 Identification Keys. The following patterns have been defined:
Key |
Pattern |
Description |
---|---|---|
GIAI | [-!"%&'()*+,./0-9:;<=>?A-Z_a-z]{4,30} | Minimum 4, Maximum 30 alphanumeric characters restricted to A-Z (uppercase), a-z (lowercase), 0-9, and the special characters listed (e.g. %, &, etc..) |
SSCC | \d{18} | Exactly 18 numeric digits |
GTIN | \d{14} | Exactly 14 numeric digits |
GLN | \d{13} | Exactly 13 numeric digits |
GSIN | \d{17} | Exactly 17 numeric digits |
GINC | [-!"%&'()*+,./0-9:;<=>?A-Z_a-z]{4,30} | Minimum 4, Maximum 30 alphanumeric characters restricted to A-Z (uppercase), a-z (lowercase), 0-9, and the special characters listed (e.g. %, &, etc..) |
GRAI | \d{14}[-!"%&'()*+,./0-9:;<=>?A-Z_a-z]{0,16} | Exactly 14 numeric digits, followed by Minimum 0, Maximum 16 alphanumeric characters restricted to A-Z (uppercase), a-z (lowercase), 0-9, and the special characters listed (e.g. %, &, etc..) |
GSRN | \d{18} | Exactly 18 numeric digits |
Handling time stamps and time zones
For data elements where time is required, two built-in data-types are used within GS1 XML standards: <xsd:dateTime> and <xsd:time>. Their value space is defined in article 5.3 of ISO 8601, the details can be found at the following links:
http://www.w3.org/TR/xmlschema-2/#time
http://www.w3.org/TR/xmlschema-2/#dateTime
For the value space of<xsd:dateTime> and <xsd:time>, additional fractional seconds (milliseconds) and Time zone information can specified.
Use of milliseconds
Both <xsd:dateTime> and <xsd:time>, data types allow use of additional digits increasing the precision of fractional seconds if desired, in the format ss.s.
‘ss.s’ denotes two digits of a second (00 through 59) followed by one or more digits representing a decimal fraction of a second (milliseconds). The fractional second part is separated from the two digits of second by the use of a ‘dot’ as a separator.
Though any number of digits for the fractional seconds is supported, only 3 precision digits should be used within GS1 XML messages to denote the milliseconds.
Example
The following values are true for the attribute 'creationDateTime' which is of type <xsd:dateTime> in all versions of GS1 XML Standards.
- <creationDateTime>2011-03-22T09:30:47</creationDateTime>
indicates 47 seconds and 0 milliseconds - <creationDateTime>2011-03-22T09:30:47.0</creationDateTime>
indicates 47 seconds and 0 milliseconds like in the example above - <creationDateTime>2011-03-22T09:30:47.233</creationDateTime>
indicates 47 seconds and 233 milliseconds
Use of time zones
Both <xsd:dateTime> and <xsd:time> data types allow specifying the time zone, following the time information. The time zone information for non-UTC1 times within GS1 System must be expressed by specifying the difference between the local time and UTC. This is indicated by immediately following the time representation by a sign, + or -, followed by the difference from UTC represented as hh:mm. Please note that the minutes part is required.
Example
- <creationDateTime>2011-11-06T12:43:17.000+09:00</creationDateTime>
indicates Tokyo Time, which is 9 hours ahead of UTC - <creationDateTime>2011-03-22T09:30:47.233-05:00</creationDateTime>
indicates Eastern Time Zone (EST), which is 5 hours behind UTC
where:
- ‘2011’ denotes the year
- ‘03’ denotes the month
- ‘22’ denotes the day
- ‘T’ denotes the time separator
- ‘09’ denotes the hours
- ‘30’ denotes the minutes
- ‘47’ denotes the seconds
- ‘.’ denotes the fractional seconds separator
- ‘233’ denotes the fractional seconds (milliseconds)
- ‘-’ denotes the time zone offset indicator indicating ‘behind UTC’
- ‘05’ denotes the hours
- ‘:’ denotes the minutes separator and ‘00’ is the minutes
1 UTC Stands for Coordinated Universal Time
Use of XML elements vs. attributes
In the GS1 XML MR 3 attributes are used only to define data type supplementary components.
Example
The ‘codeListVersion’ is an optional attribute of the ‘GS1CodeType’:
The XML elements are used to define all other constructs.