Fixed the type of the totalDigits value to be positiveInteger. Fixed crash
* xmlschemas.c xmlschemastypes.c: Fixed the type of the
totalDigits value to be positiveInteger.
Fixed crash in an error report function when we gave it
the document node; only element and attribute nodes are
processed now (reported by Rob Richards).
diff --git a/ChangeLog b/ChangeLog
index ef32813..61a0a3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Nov 7 14:58:39 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+ * xmlschemas.c xmlschemastypes.c: Fixed the type of the
+ totalDigits value to be positiveInteger.
+ Fixed crash in an error report function when we gave it
+ the document node; only element and attribute nodes are
+ processed now (reported by Rob Richards).
+
Tue Nov 1 16:22:29 CET 2005 Daniel Veillard <daniel@veillard.com>
* xmlregexp.c: fix bug #319897, problem with counted atoms
diff --git a/xmlschemas.c b/xmlschemas.c
index 858a479..d30ad07 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -2137,6 +2137,18 @@
xmlChar *str = NULL;
*msg = NULL;
+ if ((node != NULL) &&
+ (node->type != XML_ELEMENT_NODE) &&
+ (node->type != XML_ATTRIBUTE_NODE))
+ {
+ /*
+ * Don't try to format other nodes than element and
+ * attribute nodes.
+ * Play save and return an empty string.
+ */
+ *msg = xmlStrdup(BAD_CAST "");
+ return(*msg);
+ }
if (node != NULL) {
/*
* Work on tree nodes.
@@ -6225,7 +6237,8 @@
break;
default: {
PERROR_INT("xmlSchemaPValAttrNodeValue",
- "validation using the given type is not supported");
+ "validation using the given type is not supported while "
+ "parsing a schema");
return (-1);
}
}
@@ -18588,33 +18601,43 @@
case XML_SCHEMA_FACET_FRACTIONDIGITS:
case XML_SCHEMA_FACET_LENGTH:
case XML_SCHEMA_FACET_MAXLENGTH:
- case XML_SCHEMA_FACET_MINLENGTH:{
+ case XML_SCHEMA_FACET_MINLENGTH:
+
+ if (facet->type == XML_SCHEMA_FACET_TOTALDIGITS) {
+ ret = xmlSchemaValidatePredefinedType(
+ xmlSchemaGetBuiltInType(XML_SCHEMAS_PINTEGER),
+ facet->value, &(facet->val));
+ } else {
ret = xmlSchemaValidatePredefinedType(
xmlSchemaGetBuiltInType(XML_SCHEMAS_NNINTEGER),
facet->value, &(facet->val));
- if (ret != 0) {
- if (ret < 0) {
- /* No error message for RelaxNG. */
- if (ctxtGiven) {
- PERROR_INT("xmlSchemaCheckFacet",
- "validating facet value");
- }
- goto internal_error;
- }
- ret = XML_SCHEMAP_INVALID_FACET_VALUE;
+ }
+ if (ret != 0) {
+ if (ret < 0) {
/* No error message for RelaxNG. */
if (ctxtGiven) {
- /* error code */
- xmlSchemaCustomErr(ACTXT_CAST pctxt,
- ret, facet->node, WXS_BASIC_CAST typeDecl,
- "The value '%s' of the facet '%s' is not a valid "
- "'nonNegativeInteger'",
- facet->value,
- xmlSchemaFacetTypeToString(facet->type));
- }
- }
- break;
- }
+ PERROR_INT("xmlSchemaCheckFacet",
+ "validating facet value");
+ }
+ goto internal_error;
+ }
+ ret = XML_SCHEMAP_INVALID_FACET_VALUE;
+ /* No error message for RelaxNG. */
+ if (ctxtGiven) {
+ /* error code */
+ xmlSchemaCustomErr4(ACTXT_CAST pctxt,
+ ret, facet->node, WXS_BASIC_CAST typeDecl,
+ "The value '%s' of the facet '%s' is not a valid '%s'",
+ facet->value,
+ xmlSchemaFacetTypeToString(facet->type),
+ (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ?
+ BAD_CAST "nonNegativeInteger" :
+ BAD_CAST "positiveInteger",
+ NULL);
+ }
+ }
+ break;
+
case XML_SCHEMA_FACET_WHITESPACE:{
if (xmlStrEqual(facet->value, BAD_CAST "preserve")) {
facet->whitespace = XML_SCHEMAS_FACET_PRESERVE;
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index 9d99bbb..205d484 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -434,9 +434,7 @@
}
memset(wild, 0, sizeof(xmlSchemaWildcard));
wild->type = XML_SCHEMA_TYPE_ANY;
- wild->any = 1;
- wild->minOccurs = 1;
- wild->maxOccurs = 1;
+ wild->any = 1;
wild->processContents = XML_SCHEMAS_ANY_LAX;
particle->children = (xmlSchemaTreeItemPtr) wild;
/*
@@ -450,9 +448,7 @@
}
memset(wild, 0, sizeof(xmlSchemaWildcard));
wild->any = 1;
- wild->processContents = XML_SCHEMAS_ANY_LAX;
- wild->minOccurs = 1;
- wild->maxOccurs = 1;
+ wild->processContents = XML_SCHEMAS_ANY_LAX;
xmlSchemaTypeAnyTypeDef->attributeWildcard = wild;
}
xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType",
@@ -5377,7 +5373,7 @@
case XML_SCHEMA_FACET_FRACTIONDIGITS:
if ((facet->val == NULL) ||
- ((facet->val->type != XML_SCHEMAS_DECIMAL) &&
+ ((facet->val->type != XML_SCHEMAS_PINTEGER) &&
(facet->val->type != XML_SCHEMAS_NNINTEGER)) ||
(facet->val->value.decimal.frac != 0)) {
return(-1);