implemented comparisons for Schemas values. fixed some bugs in duration
* relaxng.c: implemented comparisons for Schemas values.
* xmlschemastypes.c include/libxml/xmlschemastypes.h: fixed
some bugs in duration handling, comparisons for durations
and decimals, removed all memory leaks pointed out by James
testsuite. Current status is now
found 238 test schemas: 197 success 41 failures
found 1035 test instances: 803 success 130 failures
Daniel
diff --git a/relaxng.c b/relaxng.c
index b8c0b5c..a916fda 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -2305,24 +2305,68 @@
}
/**
+ * xmlRelaxNGSchemaFreeValue:
+ * @data: data needed for the library
+ * @value: the value to free
+ *
+ * Function provided by a type library to free a Schemas value
+ *
+ * Returns 1 if yes, 0 if no and -1 in case of error.
+ */
+static void
+xmlRelaxNGSchemaFreeValue (void *data ATTRIBUTE_UNUSED, void *value) {
+ xmlSchemaFreeValue(value);
+}
+
+/**
* xmlRelaxNGSchemaTypeCompare:
* @data: data needed for the library
* @type: the type name
* @value1: the first value
* @value2: the second value
*
- * Compare two values accordingly a type from the W3C XMLSchema
+ * Compare two values for equality accordingly a type from the W3C XMLSchema
* Datatype library.
*
- * Returns 1 if yes, 0 if no and -1 in case of error.
+ * Returns 1 if equal, 0 if no and -1 in case of error.
*/
static int
xmlRelaxNGSchemaTypeCompare(void *data ATTRIBUTE_UNUSED,
const xmlChar *type ATTRIBUTE_UNUSED,
const xmlChar *value1 ATTRIBUTE_UNUSED,
const xmlChar *value2 ATTRIBUTE_UNUSED) {
- TODO
- return(1);
+ int ret;
+ xmlSchemaTypePtr typ;
+ xmlSchemaValPtr res1 = NULL, res2 = NULL;
+
+ if ((type == NULL) || (value1 == NULL) || (value2 == NULL))
+ return(-1);
+ typ = xmlSchemaGetPredefinedType(type,
+ BAD_CAST "http://www.w3.org/2001/XMLSchema");
+ if (typ == NULL)
+ return(-1);
+ ret = xmlSchemaValPredefTypeNode(typ, value1, &res1, NULL);
+ if (ret != 0)
+ return(-1);
+ if (res1 == NULL)
+ return(-1);
+ ret = xmlSchemaValPredefTypeNode(typ, value2, &res2, NULL);
+ if (ret != 0) {
+ xmlSchemaFreeValue(res1);
+ return(-1);
+ }
+ if (res1 == NULL) {
+ xmlSchemaFreeValue(res1);
+ return(-1);
+ }
+ ret = xmlSchemaCompareValues(res1, res2);
+ xmlSchemaFreeValue(res1);
+ xmlSchemaFreeValue(res2);
+ if (ret == -2)
+ return(-1);
+ if (ret == 0)
+ return(1);
+ return(0);
}
/**
@@ -2522,7 +2566,7 @@
xmlRelaxNGSchemaTypeCheck,
xmlRelaxNGSchemaTypeCompare,
xmlRelaxNGSchemaFacetCheck,
- (xmlRelaxNGTypeFree) xmlSchemaFreeValue);
+ xmlRelaxNGSchemaFreeValue);
xmlRelaxNGRegisterTypeLibrary(
xmlRelaxNGNs,
NULL,