added Datatype ID and IDREF, usable from RelaxNG now need to add a new
* relaxng.c valid.c xmlschemastypes.c: added Datatype ID
and IDREF, usable from RelaxNG now
* include/libxml/xmlschemastypes.h: need to add a new interface
because the validation modifies the infoset
* test/relaxng/testsuite.xml: extended the testsuite
Daniel
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index bda7336..a477bcc 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -1057,10 +1057,11 @@
/**
- * xmlSchemaValidatePredefinedType:
+ * xmlSchemaValPredefTypeNode:
* @type: the predefined type
* @value: the value to check
* @val: the return computed value
+ * @node: the node containing the value
*
* Check that a value conforms to the lexical space of the predefined type.
* if true a value is computed and returned in @val.
@@ -1069,8 +1070,8 @@
* and -1 in case of internal or API error.
*/
int
-xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
- xmlSchemaValPtr *val) {
+xmlSchemaValPredefTypeNode(xmlSchemaTypePtr type, const xmlChar *value,
+ xmlSchemaValPtr *val, xmlNodePtr node) {
xmlSchemaValPtr v;
int ret;
@@ -1411,6 +1412,37 @@
}
}
return(0);
+ } else if (type == xmlSchemaTypeIdrefDef) {
+ ret = xmlValidateNCName(value, 1);
+ if ((ret == 0) && (val != NULL)) {
+ TODO;
+ }
+ if ((ret == 0) && (node != NULL) &&
+ (node->type == XML_ATTRIBUTE_NODE)) {
+ xmlAttrPtr attr = (xmlAttrPtr) node;
+
+ xmlAddRef(NULL, node->doc, value, attr);
+ attr->atype = XML_ATTRIBUTE_IDREF;
+ }
+ return(ret);
+ } else if (type == xmlSchemaTypeIdDef) {
+ ret = xmlValidateNCName(value, 1);
+ if ((ret == 0) && (val != NULL)) {
+ TODO;
+ }
+ if ((ret == 0) && (node != NULL) &&
+ (node->type == XML_ATTRIBUTE_NODE)) {
+ xmlAttrPtr attr = (xmlAttrPtr) node;
+ xmlIDPtr res;
+
+ res = xmlAddID(NULL, node->doc, value, attr);
+ if (res == NULL) {
+ ret = 2;
+ } else {
+ attr->atype = XML_ATTRIBUTE_ID;
+ }
+ }
+ return(ret);
} else {
TODO
return(0);
@@ -1419,6 +1451,24 @@
}
/**
+ * xmlSchemaValidatePredefinedType:
+ * @type: the predefined type
+ * @value: the value to check
+ * @val: the return computed value
+ *
+ * Check that a value conforms to the lexical space of the predefined type.
+ * if true a value is computed and returned in @val.
+ *
+ * Returns 0 if this validates, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
+ xmlSchemaValPtr *val) {
+ return(xmlSchemaValPredefTypeNode(type, value, val, NULL));
+}
+
+/**
* xmlSchemaCompareDecimals:
* @x: a first decimal value
* @y: a second decimal value