started implementing some of the missing default simple types updated the
* xmlschemastypes.c: started implementing some of the missing
default simple types
* result/relaxng/*: updated the results
Daniel
diff --git a/ChangeLog b/ChangeLog
index 709e8ef..6cf9169 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Feb 6 10:23:52 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * 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 <daniel@veillard.com>
* NEWS doc/*: updated the docs, ready for 2.5.2 release
diff --git a/doc/FAQ.html b/doc/FAQ.html
index 84093c5..6201fe6 100644
--- a/doc/FAQ.html
+++ b/doc/FAQ.html
@@ -264,7 +264,7 @@
<p><em>but it does not work. If I change it to</em></p>
<pre>pnode=pxmlDoc->children->children->next;</pre>
<p><em>then it works. Can someone explain it to me.</em></p>
- <p></p>
+ <p>
<p>In XML all characters in the content of the document are significant
<strong>including blanks and formatting line breaks</strong>.</p>
<p>The extra nodes you are wondering about are just that, text nodes with
@@ -367,7 +367,7 @@
</li>
<li>etc ...</li>
</ol>
-<p></p>
+<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>
diff --git a/doc/architecture.html b/doc/architecture.html
index 4762ba8..7f3844e 100644
--- a/doc/architecture.html
+++ b/doc/architecture.html
@@ -113,7 +113,7 @@
</ul>
<p>Graphically this gives the following:</p>
<p><img src="libxml.gif" alt="a graphical view of the various"></p>
-<p></p>
+<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>
diff --git a/doc/catalog.html b/doc/catalog.html
index 706ca47..ee8adc3 100644
--- a/doc/catalog.html
+++ b/doc/catalog.html
@@ -149,7 +149,7 @@
Catalogs</a> is far more flexible, more recent, uses an XML syntax and
should scale quite better. This is the default option of libxml.</li>
</ul>
-<p></p>
+<p>
<h3><a name="Simple">Using catalog</a></h3>
<p>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 @@
try to avoid troubles in multithreaded environments. The code is now thread
safe assuming that the libxml library has been compiled with threads
support.</p>
-<p></p>
+<p>
<h3><a name="Other">Other resources</a></h3>
<p>The XML Catalog specification is relatively recent so there isn't much
literature to point at:</p>
diff --git a/doc/contribs.html b/doc/contribs.html
index cc7fd69..77b7e20 100644
--- a/doc/contribs.html
+++ b/doc/contribs.html
@@ -136,7 +136,7 @@
Digital Signature</a> <a href="http://www.aleksey.com/xmlsec/">implementations for libxml2</a>
</li>
</ul>
-<p></p>
+<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>
diff --git a/doc/index.html b/doc/index.html
index ce96e6c..4556ab2 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -95,7 +95,7 @@
</table>
</td></tr></table></td>
<td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd">
-<p></p>
+<p>
<p>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 2e129fc..c6c2528 100644
--- a/doc/xmldtd.html
+++ b/doc/xmldtd.html
@@ -249,7 +249,7 @@
<p>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.</p>
-<p></p>
+<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>
diff --git a/doc/xmlmem.html b/doc/xmlmem.html
index f863c80..ddce58c 100644
--- a/doc/xmlmem.html
+++ b/doc/xmlmem.html
@@ -218,7 +218,7 @@
validation, DOM, XPath or XPointer, but really need to work fixed memory
requirements, then the SAX interface should be used.</li>
</ul>
-<p></p>
+<p>
<p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table>
diff --git a/result/relaxng/tutor5_1_1.err b/result/relaxng/tutor5_1_1.err
index b0327a3..e69de29 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 3a2e39a..e69de29 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 ddad47b..e69de29 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 3fccaa4..dea493f 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 6e686bc..17a46f6 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 ddad47b..e69de29 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 d43fbb1..e69de29 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 c617851..e69de29 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 3a2e39a..e69de29 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 3a2e39a..e69de29 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 745014d..e69de29 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 ad64637..e69de29 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 4fc9c7d..17a46f6 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 7c13914..dea493f 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 f7fc982..aff3e57 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -18,6 +18,8 @@
#include <libxml/parserInternals.h>
#include <libxml/hash.h>
#include <libxml/valid.h>
+#include <libxml/xpath.h>
+#include <libxml/uri.h>
#include <libxml/xmlschemas.h>
#include <libxml/schemasInternals.h>
@@ -53,6 +55,7 @@
XML_SCHEMAS_DURATION,
XML_SCHEMAS_FLOAT,
XML_SCHEMAS_DOUBLE,
+ XML_SCHEMAS_INT,
XML_SCHEMAS_,
XML_SCHEMAS_XXX
} xmlSchemaValType;
@@ -129,6 +132,7 @@
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 @@
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float");
xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double");
+ xmlSchemaTypeNameDef = xmlSchemaInitBasicType("Name");
xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName");
xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI");
@@ -965,6 +970,137 @@
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 @@
xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
xmlSchemaValPtr *val) {
xmlSchemaValPtr v;
+ int ret;
if (xmlSchemaTypesInitialized == 0)
return(-1);
@@ -1108,42 +1245,195 @@
}
}
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);
}
/**