Search code examples
xmltypessemantic-web

How to recognize a gYear value?


As we know, each xml datatype has a specific format. For example:

xs:gYearMonth => 2001-10 or 2001-10+02:00 or 2001-10Z ... xs:dateTime => 2001-10-26T21:32:52 or 2001-10-26T21:32:52+02:00 or 2001-10-26T19:32:52Z ...

In the case of xs:gYear => these are all the possibilities:

2001, 2001+02:00, 2001Z, 2001+00:00, -2001, -20000

and the datatype xs:Decimal :

123, 123.456, +1234.456, -1234.456, -.456, -456

So there is small intersection (values 2001, 123), how can i know if the value is a gYear or Decimal datatype?


Solution

  • You can't.

    Or at least, you can't always tell from the lexical representation alone.

    As such you can't know from that alone whether 2016 means the current year or the number of 5-cubes in a 9-cube.

    You need to infer from context or other information (schema annotations).