diff --git a/ChangeLog b/ChangeLog
index 709e8eff..6cf9169d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Feb 6 10:23:52 CET 2003 Daniel Veillard
+
+ * xmlschemastypes.c: started implementing some of the missing
+ default simple types
+ * result/relaxng/*: updated the results
+
Wed Feb 5 15:28:04 CET 2003 Daniel Veillard
* NEWS doc/*: updated the docs, ready for 2.5.2 release
diff --git a/doc/FAQ.html b/doc/FAQ.html
index 84093c5c..6201fe6a 100644
--- a/doc/FAQ.html
+++ b/doc/FAQ.html
@@ -264,7 +264,7 @@ pnode=pxmlDoc->children->children;
but it does not work. If I change it to
pnode=pxmlDoc->children->children->next;
then it works. Can someone explain it to me.
-
+
In XML all characters in the content of the document are significant
including blanks and formatting line breaks.
The extra nodes you are wondering about are just that, text nodes with
@@ -367,7 +367,7 @@ xmlDtdPtr dtd = xmlParseDTD(NULL, filename_of_dtd); /* parse the DTD */
etc ...
-
+
Daniel Veillard
diff --git a/doc/architecture.html b/doc/architecture.html
index 4762ba80..7f3844e8 100644
--- a/doc/architecture.html
+++ b/doc/architecture.html
@@ -113,7 +113,7 @@ of the block interfaces are public. The main components are:
Graphically this gives the following:

-
+
Daniel Veillard
diff --git a/doc/catalog.html b/doc/catalog.html
index 706ca47c..ee8adc38 100644
--- a/doc/catalog.html
+++ b/doc/catalog.html
@@ -149,7 +149,7 @@ started.
Catalogs is far more flexible, more recent, uses an XML syntax and
should scale quite better. This is the default option of libxml.
-
+
In a normal environment libxml will by default check the presence of a
catalog in /etc/xml/catalog, and assuming it has been correctly populated,
@@ -388,7 +388,7 @@ provided because this functionality may be useful for client tools.
try to avoid troubles in multithreaded environments. The code is now thread
safe assuming that the libxml library has been compiled with threads
support.
-
+
The XML Catalog specification is relatively recent so there isn't much
literature to point at:
diff --git a/doc/contribs.html b/doc/contribs.html
index cc7fd694..77b7e201 100644
--- a/doc/contribs.html
+++ b/doc/contribs.html
@@ -136,7 +136,7 @@ A:link, A:visited, A:active { text-decoration: underline }
Digital Signature implementations for libxml2
-
+
Daniel Veillard
diff --git a/doc/index.html b/doc/index.html
index ce96e6ca..4556ab20 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -95,7 +95,7 @@ A:link, A:visited, A:active { text-decoration: underline }
-
+
Libxml is the XML C library developed for the Gnome project. XML itself
is a metalanguage to design markup languages, i.e. text language where
semantic and structure are added to the content using extra "markup"
diff --git a/doc/xmldtd.html b/doc/xmldtd.html
index 2e129fcb..c6c25281 100644
--- a/doc/xmldtd.html
+++ b/doc/xmldtd.html
@@ -249,7 +249,7 @@ will just list one for now, others pointers welcome:
I suggest looking at the examples found under test/valid/dtd and any of
the large number of books available on XML. The dia example in test/valid
should be both simple and complete enough to allow you to build your own.
-
+
Daniel Veillard
|
|
|
|
diff --git a/doc/xmlmem.html b/doc/xmlmem.html
index f863c80d..ddce58c3 100644
--- a/doc/xmlmem.html
+++ b/doc/xmlmem.html
@@ -218,7 +218,7 @@ of a number of things:
validation, DOM, XPath or XPointer, but really need to work fixed memory
requirements, then the SAX interface should be used.
-
+
Daniel Veillard
diff --git a/result/relaxng/tutor5_1_1.err b/result/relaxng/tutor5_1_1.err
index b0327a3d..e69de29b 100644
--- a/result/relaxng/tutor5_1_1.err
+++ b/result/relaxng/tutor5_1_1.err
@@ -1 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1144
diff --git a/result/relaxng/tutor5_2_1.err b/result/relaxng/tutor5_2_1.err
index 3a2e39a5..e69de29b 100644
--- a/result/relaxng/tutor5_2_1.err
+++ b/result/relaxng/tutor5_2_1.err
@@ -1,2 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_1_1.err b/result/relaxng/tutor7_1_1.err
index ddad47b7..e69de29b 100644
--- a/result/relaxng/tutor7_1_1.err
+++ b/result/relaxng/tutor7_1_1.err
@@ -1,2 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1138
-Unimplemented block at xmlschemastypes.c:1138
diff --git a/result/relaxng/tutor7_1_2.err b/result/relaxng/tutor7_1_2.err
index 3fccaa4d..dea493fd 100644
--- a/result/relaxng/tutor7_1_2.err
+++ b/result/relaxng/tutor7_1_2.err
@@ -1,4 +1,3 @@
-Unimplemented block at xmlschemastypes.c:1138
error detected at relaxng.c:4164
error detected at relaxng.c:5255
error detected at relaxng.c:5053
diff --git a/result/relaxng/tutor7_1_3.err b/result/relaxng/tutor7_1_3.err
index 6e686bc0..17a46f66 100644
--- a/result/relaxng/tutor7_1_3.err
+++ b/result/relaxng/tutor7_1_3.err
@@ -1,5 +1,3 @@
-Unimplemented block at xmlschemastypes.c:1138
-Unimplemented block at xmlschemastypes.c:1138
error detected at relaxng.c:4353
error detected at relaxng.c:5255
error detected at relaxng.c:5053
diff --git a/result/relaxng/tutor7_1_4.err b/result/relaxng/tutor7_1_4.err
index ddad47b7..e69de29b 100644
--- a/result/relaxng/tutor7_1_4.err
+++ b/result/relaxng/tutor7_1_4.err
@@ -1,2 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1138
-Unimplemented block at xmlschemastypes.c:1138
diff --git a/result/relaxng/tutor7_2_1.err b/result/relaxng/tutor7_2_1.err
index d43fbb1c..e69de29b 100644
--- a/result/relaxng/tutor7_2_1.err
+++ b/result/relaxng/tutor7_2_1.err
@@ -1 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_2_2.err b/result/relaxng/tutor7_2_2.err
index c6178511..e69de29b 100644
--- a/result/relaxng/tutor7_2_2.err
+++ b/result/relaxng/tutor7_2_2.err
@@ -1,3 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_2_3.err b/result/relaxng/tutor7_2_3.err
index 3a2e39a5..e69de29b 100644
--- a/result/relaxng/tutor7_2_3.err
+++ b/result/relaxng/tutor7_2_3.err
@@ -1,2 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_3_1.err b/result/relaxng/tutor7_3_1.err
index 3a2e39a5..e69de29b 100644
--- a/result/relaxng/tutor7_3_1.err
+++ b/result/relaxng/tutor7_3_1.err
@@ -1,2 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_3_2.err b/result/relaxng/tutor7_3_2.err
index 745014db..e69de29b 100644
--- a/result/relaxng/tutor7_3_2.err
+++ b/result/relaxng/tutor7_3_2.err
@@ -1,6 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_3_3.err b/result/relaxng/tutor7_3_3.err
index ad646373..e69de29b 100644
--- a/result/relaxng/tutor7_3_3.err
+++ b/result/relaxng/tutor7_3_3.err
@@ -1,4 +0,0 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
diff --git a/result/relaxng/tutor7_3_4.err b/result/relaxng/tutor7_3_4.err
index 4fc9c7d5..17a46f66 100644
--- a/result/relaxng/tutor7_3_4.err
+++ b/result/relaxng/tutor7_3_4.err
@@ -1,6 +1,3 @@
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
-Unimplemented block at xmlschemastypes.c:1141
error detected at relaxng.c:4353
error detected at relaxng.c:5255
error detected at relaxng.c:5053
diff --git a/result/relaxng/tutor7_3_5.err b/result/relaxng/tutor7_3_5.err
index 7c139143..dea493fd 100644
--- a/result/relaxng/tutor7_3_5.err
+++ b/result/relaxng/tutor7_3_5.err
@@ -1,4 +1,3 @@
-Unimplemented block at xmlschemastypes.c:1141
error detected at relaxng.c:4164
error detected at relaxng.c:5255
error detected at relaxng.c:5053
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index f7fc9823..aff3e575 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -18,6 +18,8 @@
#include
#include
#include
+#include
+#include
#include
#include
@@ -53,6 +55,7 @@ typedef enum {
XML_SCHEMAS_DURATION,
XML_SCHEMAS_FLOAT,
XML_SCHEMAS_DOUBLE,
+ XML_SCHEMAS_INT,
XML_SCHEMAS_,
XML_SCHEMAS_XXX
} xmlSchemaValType;
@@ -129,6 +132,7 @@ static xmlSchemaTypePtr xmlSchemaTypeDurationDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL;
static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL;
+static xmlSchemaTypePtr xmlSchemaTypeNameDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeQNameDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL;
@@ -205,6 +209,7 @@ xmlSchemaInitTypes(void) {
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float");
xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double");
+ xmlSchemaTypeNameDef = xmlSchemaInitBasicType("Name");
xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName");
xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI");
@@ -965,6 +970,137 @@ error:
return 1;
}
+
+/**
+ * xmlSchemaValidateNCName:
+ * @value: the value to check
+ *
+ * Check that a value conforms to the lexical space of NCName
+ *
+ * Returns 0 if this validates, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+static int
+xmlSchemaValidateNCName(const xmlChar *value) {
+ const xmlChar *cur = value;
+
+ /*
+ * First quick algorithm for ASCII range
+ */
+ while (IS_BLANK(*cur)) cur++;
+ if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
+ (*cur == '_'))
+ cur++;
+ else
+ goto try_complex;
+ while (((*cur >= 'a') && (*cur <= 'z')) ||
+ ((*cur >= 'A') && (*cur <= 'Z')) ||
+ ((*cur >= '0') && (*cur <= '9')) ||
+ (*cur == '_') || (*cur == '-') || (*cur == '.'))
+ cur++;
+ while (IS_BLANK(*cur)) cur++;
+ if (*cur == 0)
+ return(0);
+
+try_complex:
+ /*
+ * Second check for chars outside the ASCII range
+ */
+ TODO
+ return(0);
+}
+
+/**
+ * xmlSchemaValidateQName:
+ * @value: the value to check
+ *
+ * Check that a value conforms to the lexical space of QName
+ *
+ * Returns 0 if this validates, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+static int
+xmlSchemaValidateQName(const xmlChar *value) {
+ const xmlChar *cur = value;
+
+ /*
+ * First quick algorithm for ASCII range
+ */
+ while (IS_BLANK(*cur)) cur++;
+ if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
+ (*cur == '_'))
+ cur++;
+ else
+ goto try_complex;
+ while (((*cur >= 'a') && (*cur <= 'z')) ||
+ ((*cur >= 'A') && (*cur <= 'Z')) ||
+ ((*cur >= '0') && (*cur <= '9')) ||
+ (*cur == '_') || (*cur == '-') || (*cur == '.'))
+ cur++;
+ if (*cur == ':') {
+ cur++;
+ if (((*cur >= 'a') && (*cur <= 'z')) ||
+ ((*cur >= 'A') && (*cur <= 'Z')) ||
+ (*cur == '_'))
+ cur++;
+ else
+ goto try_complex;
+ while (((*cur >= 'a') && (*cur <= 'z')) ||
+ ((*cur >= 'A') && (*cur <= 'Z')) ||
+ ((*cur >= '0') && (*cur <= '9')) ||
+ (*cur == '_') || (*cur == '-') || (*cur == '.'))
+ cur++;
+ }
+ while (IS_BLANK(*cur)) cur++;
+ if (*cur == 0)
+ return(0);
+
+try_complex:
+ /*
+ * Second check for chars outside the ASCII range
+ */
+ TODO
+ return(0);
+}
+
+/**
+ * xmlSchemaValidateName:
+ * @value: the value to check
+ *
+ * Check that a value conforms to the lexical space of Name
+ *
+ * Returns 0 if this validates, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+static int
+xmlSchemaValidateName(const xmlChar *value) {
+ const xmlChar *cur = value;
+
+ /*
+ * First quick algorithm for ASCII range
+ */
+ while (IS_BLANK(*cur)) cur++;
+ if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
+ (*cur == '_') || (*cur == ':'))
+ cur++;
+ else
+ goto try_complex;
+ while (((*cur >= 'a') && (*cur <= 'z')) ||
+ ((*cur >= 'A') && (*cur <= 'Z')) ||
+ ((*cur >= '0') && (*cur <= '9')) ||
+ (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':'))
+ cur++;
+ while (IS_BLANK(*cur)) cur++;
+ if (*cur == 0)
+ return(0);
+
+try_complex:
+ /*
+ * Second check for chars outside the ASCII range
+ */
+ TODO
+ return(0);
+}
/**
* xmlSchemaValidatePredefinedType:
* @type: the predefined type
@@ -981,6 +1117,7 @@ int
xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
xmlSchemaValPtr *val) {
xmlSchemaValPtr v;
+ int ret;
if (xmlSchemaTypesInitialized == 0)
return(-1);
@@ -1108,42 +1245,195 @@ xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
}
}
return(0);
- } else if (type == xmlSchemaTypeFloatDef) {
- const xmlChar *cur = value, *tmp;
- int frac = 0, len, neg = 0;
+ } else if (type == xmlSchemaTypeIntDef) {
+ const xmlChar *cur = value;
unsigned long base = 0;
+ int total = 0;
+ int sign = 0;
if (cur == NULL)
return(1);
+ if (*cur == '-') {
+ sign = 1;
+ cur++;
+ } else if (*cur == '+')
+ cur++;
+ while (*cur == '0') {
+ total++;
+ cur++;
+ }
+ while ((*cur >= '0') && (*cur <= '9')) {
+ base = base * 10 + (*cur - '0');
+ total++;
+ cur++;
+ }
+ if (*cur != 0)
+ return(1);
+ if ((sign == 1) && (total == 0))
+ return(1);
+ if (val != NULL) {
+ v = xmlSchemaNewValue(XML_SCHEMAS_INT);
+ if (v != NULL) {
+ v->value.decimal.base = base;
+ v->value.decimal.sign = sign;
+ v->value.decimal.frac = 0;
+ v->value.decimal.total = total;
+ *val = v;
+ }
+ }
+ return(0);
+ } else if ((type == xmlSchemaTypeFloatDef) ||
+ (type == xmlSchemaTypeDoubleDef)) {
+ const xmlChar *cur = value;
+ int neg = 0;
+ if (cur == NULL)
+ return(1);
+ if ((cur[0] == 'N') && (cur[1] == 'a') && (cur[2] == 'N')) {
+ cur += 3;
+ if (*cur != 0)
+ return(1);
+ if (val != NULL) {
+ if (type == xmlSchemaTypeFloatDef) {
+ v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);
+ if (v != NULL) {
+ v->value.f = (float) xmlXPathNAN;
+ } else {
+ xmlSchemaFreeValue(v);
+ return(-1);
+ }
+ } else {
+ v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);
+ if (v != NULL) {
+ v->value.d = xmlXPathNAN;
+ } else {
+ xmlSchemaFreeValue(v);
+ return(-1);
+ }
+ }
+ *val = v;
+ }
+ return(0);
+ }
if (*cur == '+')
cur++;
else if (*cur == '-') {
neg = 1;
cur++;
}
- tmp = cur;
+ if ((cur[0] == 'I') && (cur[1] == 'N') && (cur[2] == 'F')) {
+ cur += 3;
+ if (*cur != 0)
+ return(1);
+ if (val != NULL) {
+ if (type == xmlSchemaTypeFloatDef) {
+ v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);
+ if (v != NULL) {
+ if (neg)
+ v->value.f = (float) xmlXPathNINF;
+ else
+ v->value.f = (float) xmlXPathPINF;
+ } else {
+ xmlSchemaFreeValue(v);
+ return(-1);
+ }
+ } else {
+ v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);
+ if (v != NULL) {
+ if (neg)
+ v->value.d = xmlXPathNINF;
+ else
+ v->value.d = xmlXPathPINF;
+ } else {
+ xmlSchemaFreeValue(v);
+ return(-1);
+ }
+ }
+ *val = v;
+ }
+ return(0);
+ }
while ((*cur >= '0') && (*cur <= '9')) {
- base = base * 10 + (*cur - '0');
cur++;
}
- len = cur - tmp;
if (*cur == '.') {
cur++;
- tmp = cur;
- while ((*cur >= '0') && (*cur <= '9')) {
- base = base * 10 + (*cur - '0');
+ while ((*cur >= '0') && (*cur <= '9'))
cur++;
- }
- frac = cur - tmp;
}
- TODO
+ if ((*cur == 'e') || (*cur == 'E')) {
+ cur++;
+ if (*cur == '-')
+ cur++;
+ while ((*cur >= '0') && (*cur <= '9'))
+ cur++;
+ }
+ if (*cur != 0)
+ return(1);
+ if (val != NULL) {
+ if (type == xmlSchemaTypeFloatDef) {
+ v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);
+ if (v != NULL) {
+ if (sscanf((const char *)value, "%f", &(v->value.f))==1) {
+ *val = v;
+ } else {
+ xmlGenericError(xmlGenericErrorContext,
+ "failed to scanf float %s\n", value);
+ xmlSchemaFreeValue(v);
+ return(1);
+ }
+ } else {
+ return(-1);
+ }
+ } else {
+ v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);
+ if (v != NULL) {
+ if (sscanf((const char *)value, "%lf", &(v->value.d))==1) {
+ *val = v;
+ } else {
+ xmlGenericError(xmlGenericErrorContext,
+ "failed to scanf double %s\n", value);
+ xmlSchemaFreeValue(v);
+ return(1);
+ }
+ } else {
+ return(-1);
+ }
+ }
+ }
return(0);
- } else if (type == xmlSchemaTypeDoubleDef) {
- TODO
+ } else if (type == xmlSchemaTypeNameDef) {
+ ret = xmlSchemaValidateName(value);
+ if ((ret == 0) && (val != NULL)) {
+ TODO;
+ }
+ return(ret);
+ } else if (type == xmlSchemaTypeQNameDef) {
+ ret = xmlSchemaValidateQName(value);
+ if ((ret == 0) && (val != NULL)) {
+ TODO;
+ }
+ return(ret);
+ } else if (type == xmlSchemaTypeNCNameDef) {
+ ret = xmlSchemaValidateNCName(value);
+ if ((ret == 0) && (val != NULL)) {
+ TODO;
+ }
+ return(ret);
+ } else if (type == xmlSchemaTypeAnyURIDef) {
+ xmlURIPtr uri;
+
+ uri = xmlParseURI((const char *) value);
+ if (uri == NULL)
+ return(1);
+ if (val != NULL) {
+ TODO;
+ }
+ xmlFreeURI(uri);
return(0);
} else {
TODO
return(0);
}
+ return(-1);
}
/**