Currently, _parse_xsd_gyear and _parse_xsd_gyearmonth in basyx/aas/model/datatypes.py reject any xs:gYear or xs:gYearMonth
value whose year has more than 4 digits or starts with a negative sign. For example, "-2001" (valid xs:gYear), "20000" (valid xs:gYear),
"-2001-10" (valid xs:gYearMonth), and "-20000-04" (valid xs:gYearMonth) all raise:
ValueError: Value is not a valid XSD GYear/GYearMonth string
The root cause is in the two regexes at lines 639–642:
GYEAR_RE = re.compile(r'^(\d\d\d\d)([+\-]\d\d:\d\d|Z)?$')
GYEARMONTH_RE = re.compile(r'^(\d\d\d\d)-(\d\d)([+\-]\d\d:\d\d|Z)?$')
Both only match exactly 4-digit, non-negative years. The XSD specification for xs:gYear and xs:gYearMonth allows years with at least 4 digits
and an optional leading minus sign.
Notably, GYear and GYearMonth store year as a plain Python int, so there is no representation barrier here (unlike xs:date, #565), which is bounded by datetime.date's year range. The fix is purely in the regexes and the sign handling in the two parser functions.
_parse_xsd_gyear and _parse_xsd_gyearmonth then need to apply the sign from match[1] and use the renumbered capture groups.
Currently,
_parse_xsd_gyearand_parse_xsd_gyearmonthinbasyx/aas/model/datatypes.pyreject anyxs:gYearorxs:gYearMonthvalue whose year has more than 4 digits or starts with a negative sign. For example,
"-2001"(validxs:gYear),"20000"(validxs:gYear),"-2001-10"(validxs:gYearMonth), and"-20000-04"(validxs:gYearMonth) all raise:The root cause is in the two regexes at lines 639–642:
Both only match exactly 4-digit, non-negative years. The XSD specification for xs:gYear and xs:gYearMonth allows years with at least 4 digits
and an optional leading minus sign.
Notably,
GYearandGYearMonthstore year as a plain Pythonint, so there is no representation barrier here (unlike xs:date, #565), which is bounded bydatetime.date'syear range. The fix is purely in the regexes and the sign handling in the two parser functions._parse_xsd_gyearand_parse_xsd_gyearmonththen need to apply the sign frommatch[1]and use the renumbered capture groups.