Home | About GS1 | Products & Solutions | Services | Sectors | Contact GS1
 
XML
 - Overview
 - Technical
 - Implementation
 - Support
 - Training
 

XML built-in types

Return to Table of Contents

The XML standard developed by the World Wide Web Consortium (W3C) lists 44 data types that are embedded 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.

In GS1 standards, only a subset of the built-in types is used. Some of the W3C data types have different representation in the Business Message Standards than the standard one used in the schema. This difference is due to the fact that the BMS contains a UML representation of the business document, which is meant to be independent from the syntax to which it will finally be mapped.

The list of W3C data types used in GS1 standards, together with their representation in the schema and the BMS is presented below:

W3C Data Type W3C XSD GS1 BMS Data Type
string   ANString
boolean

true/false
1/0

Y/N
decimal totalDigits=5
fractionDigits=3
Numeric 5,3
integer totalDigits=5
Number 5
nonNegativeInteger totalDigits=5 Number 5
float    
dateTime

ISO 8601

Year:
YYYY (e.g. 1997)

Year and month:
YYYY-MM (e.g. 1997-07)

Complete date:
YYYY-MM-DD (e.g. 1997-07-16)

Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (e.g. 1997-07-16T19:20+01:00)

Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (e.g. 1997-07-16T19:20:30+01:00)

Complete date plus hours, minutes, seconds and a decimal fraction of a second:
YYYY-MM-DDThh:mm:ss.sTZD (e.g. 1997-07-16T19:20:30.45+01:00)

where:
YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)

CCYYMMDDThh:mm:ss
time ISO 8601 – structures related to time:
hh:mm:ss.s – explanations and examples – see dateTime
 
date ISO 8601 ISO 8601 – structures related to date:
YYYY-MM-DD – explanations and examples – see dateTime
 

W3C data types currently NOT used by GS1:

  • normalizedString
  • token
  • Name
  • NCName
  • ID
  • IDREF
  • IDREFS
  • ENTITY
  • ENTITIESNMTOKEN
  • NMTOKENS
  • nonPositiveInteger
  • negativeInteger
  • long§ language
  • int
  • short§ byte
  • unsignedLong
  • unsignedInt
  • unsignedShort
  • unsignedByte
  • positiveInteger
  • double
  • duration
  • gYearMonth
  • gYear
  • gMonthDay
  • gDay
  • gMonth
  • hexBinary
  • Base64Binary
  • anyURI
  • QName
  • NOTATION

TOP

Handling date and time

For data elements where time is required, two built-in data-types are used within GS1 XML standards: 'dateTime' and 'time'. The value space of ‘time’ and ‘dateTime’ XSD data types 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

As per the value space of ‘time’ and ‘dateTime’, additional fractional seconds (milliseconds) and Time zone information can specified.

Use of milliseconds

Both ‘time’ and ‘dateTime’ 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 second (00 through 59) followed by one or more digits representing a decimal fraction of a second (milliseconds). The fractional seconds 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 1

The following values are true for the attribute 'creationDate' which is of type XSD 'dateTime' in all versions of GS1 XML Standards.

  • creationDate="2003-03-22T09:30:47"
    The example above indicates 47 seconds and 0 milliseconds.
  • creationDate="2003-03-22T09:30:47.0"
    The example above indicates 47 seconds and 0 milliseconds and is equivalent to example 1 from above.
  • creationDate="2003-03-22T09:30:47.233"
    The example above indicates 47 seconds and 233 milliseconds.

Use of time zones

Both ‘time’ and ‘dateTime’ data types allow specifying the time zone, following the time information. The time zone information for non-UTC 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 (note: the minutes part is required).

Example 2

  • creationDate="2003-03-22T09:30:47.233-05:00"
    The example above indicates Eastern Time (ET), which is 5 hours behind UTC.
  • creationDate="2004-11-06T12:43:17.000+09:00"
    The example above indicates Tokyo Time, which is 9 hours ahead of UTC.

Example 3

A composite example of the XSD data type ‘dateTime’ following the above mentioned guidelines:

  • creationDate="2003-03-22T09:30:47.233-05:00"

    where:

    • ‘2003’ 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

Return to Table of Contents

TOP

 
Disclaimer/Copyright | Privacy | Sitemap | Contact webmaster