fixed gMonth parsing routine accordingly to the XML Schemas errata

* xmlschemastypes.c: fixed gMonth parsing routine accordingly
  to the XML Schemas errata
  http://www.w3.org/2001/05/xmlschema-errata#e2-12
Daniel
This commit is contained in:
Daniel Veillard 2003-03-31 10:13:23 +00:00
parent e637c4ad2e
commit 455cc07308
2 changed files with 23 additions and 16 deletions

View File

@ -1,3 +1,9 @@
Mon Mar 31 12:11:47 CEST 2003 Daniel Veillard <daniel@veillard.com>
* xmlschemastypes.c: fixed gMonth parsing routine accordingly
to the XML Schemas errata
http://www.w3.org/2001/05/xmlschema-errata#e2-12
Sun Mar 30 23:04:18 CEST 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c xmlschemastypes.c: more work on XML Schemas datatypes

View File

@ -837,7 +837,7 @@ _xmlSchemaParseTimeZone (xmlSchemaValDatePtr dt, const xmlChar **str) {
/**
* xmlSchemaValidateDates:
* @type: the predefined type
* @type: the expected type or XML_SCHEMAS_UNKNOWN
* @dateTime: string to analyze
* @val: the return computed value
*
@ -848,7 +848,7 @@ _xmlSchemaParseTimeZone (xmlSchemaValDatePtr dt, const xmlChar **str) {
* and -1 in case of internal or API error.
*/
static int
xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
xmlSchemaValidateDates (xmlSchemaValType type,
const xmlChar *dateTime, xmlSchemaValPtr *val) {
xmlSchemaValPtr dt;
int ret;
@ -861,11 +861,7 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
if (*cur != 0) \
goto error; \
dt->type = t; \
if (val != NULL) \
*val = dt; \
else \
xmlSchemaFreeValue(dt); \
return 0; \
goto done; \
} \
}
@ -888,6 +884,8 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
/* is it an xs:gDay? */
if (*cur == '-') {
if (type == XML_SCHEMAS_GMONTH)
goto error;
++cur;
ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
if (ret != 0)
@ -905,18 +903,14 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
if (ret != 0)
goto error;
if (*cur != '-')
goto error;
cur++;
/* is it an xs:gMonth? */
if (*cur == '-') {
cur++;
if (*cur != '-') {
RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH);
goto error;
}
if (type == XML_SCHEMAS_GMONTH)
goto error;
/* it should be an xs:gMonthDay */
cur++;
ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
if (ret != 0)
goto error;
@ -983,8 +977,15 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
if ((ret != 0) || (*cur != 0) || !VALID_DATETIME((&(dt->value.date))))
goto error;
dt->type = XML_SCHEMAS_DATETIME;
done:
#if 0
if ((type != XML_SCHEMAS_UNKNOWN) && (type != XML_SCHEMAS_DATETIME))
goto error;
#endif
if (val != NULL)
*val = dt;
else
@ -1404,7 +1405,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar *value,
case XML_SCHEMAS_GYEARMONTH:
case XML_SCHEMAS_DATE:
case XML_SCHEMAS_DATETIME:
ret = xmlSchemaValidateDates(type, value, val);
ret = xmlSchemaValidateDates(type->flags, value, val);
break;
case XML_SCHEMAS_DURATION:
ret = xmlSchemaValidateDuration(type, value, val);