1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-07 06:43:02 +03:00

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
This commit is contained in:
Daniel Veillard
2003-02-06 08:22:32 +00:00
parent 72fef16e5c
commit 96a4b25245
23 changed files with 319 additions and 55 deletions

View File

@@ -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> Wed Feb 5 15:28:04 CET 2003 Daniel Veillard <daniel@veillard.com>
* NEWS doc/*: updated the docs, ready for 2.5.2 release * NEWS doc/*: updated the docs, ready for 2.5.2 release

View File

@@ -264,7 +264,7 @@ pnode=pxmlDoc-&gt;children-&gt;children;</pre>
<p><em>but it does not work. If I change it to</em></p> <p><em>but it does not work. If I change it to</em></p>
<pre>pnode=pxmlDoc-&gt;children-&gt;children-&gt;next;</pre> <pre>pnode=pxmlDoc-&gt;children-&gt;children-&gt;next;</pre>
<p><em>then it works. Can someone explain it to me.</em></p> <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 <p>In XML all characters in the content of the document are significant
<strong>including blanks and formatting line breaks</strong>.</p> <strong>including blanks and formatting line breaks</strong>.</p>
<p>The extra nodes you are wondering about are just that, text nodes with <p>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 */
</li> </li>
<li>etc ...</li> <li>etc ...</li>
</ol> </ol>
<p></p> <p>
<p><a href="bugs.html">Daniel Veillard</a></p> <p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td> </td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table> </tr></table></td></tr></table>

View File

@@ -113,7 +113,7 @@ of the block interfaces are public. The main components are:</p>
</ul> </ul>
<p>Graphically this gives the following:</p> <p>Graphically this gives the following:</p>
<p><img src="libxml.gif" alt="a graphical view of the various"></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> <p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td> </td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table> </tr></table></td></tr></table>

View File

@@ -149,7 +149,7 @@ started.</p>
Catalogs</a> is far more flexible, more recent, uses an XML syntax and 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> should scale quite better. This is the default option of libxml.</li>
</ul> </ul>
<p></p> <p>
<h3><a name="Simple">Using catalog</a></h3> <h3><a name="Simple">Using catalog</a></h3>
<p>In a normal environment libxml will by default check the presence of a <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, 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.</p>
try to avoid troubles in multithreaded environments. The code is now thread try to avoid troubles in multithreaded environments. The code is now thread
safe assuming that the libxml library has been compiled with threads safe assuming that the libxml library has been compiled with threads
support.</p> support.</p>
<p></p> <p>
<h3><a name="Other">Other resources</a></h3> <h3><a name="Other">Other resources</a></h3>
<p>The XML Catalog specification is relatively recent so there isn't much <p>The XML Catalog specification is relatively recent so there isn't much
literature to point at:</p> literature to point at:</p>

View File

@@ -136,7 +136,7 @@ A:link, A:visited, A:active { text-decoration: underline }
Digital Signature</a> <a href="http://www.aleksey.com/xmlsec/">implementations for libxml2</a> Digital Signature</a> <a href="http://www.aleksey.com/xmlsec/">implementations for libxml2</a>
</li> </li>
</ul> </ul>
<p></p> <p>
<p><a href="bugs.html">Daniel Veillard</a></p> <p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td> </td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table> </tr></table></td></tr></table>

View File

@@ -95,7 +95,7 @@ A:link, A:visited, A:active { text-decoration: underline }
</table> </table>
</td></tr></table></td> </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"> <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 <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 is a metalanguage to design markup languages, i.e. text language where
semantic and structure are added to the content using extra &quot;markup&quot; semantic and structure are added to the content using extra &quot;markup&quot;

View File

@@ -249,7 +249,7 @@ will just list one for now, others pointers welcome:</p>
<p>I suggest looking at the examples found under test/valid/dtd and any of <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 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> 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> <p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td> </td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table> </tr></table></td></tr></table>

View File

@@ -218,7 +218,7 @@ of a number of things:</p>
validation, DOM, XPath or XPointer, but really need to work fixed memory validation, DOM, XPath or XPointer, but really need to work fixed memory
requirements, then the SAX interface should be used.</li> requirements, then the SAX interface should be used.</li>
</ul> </ul>
<p></p> <p>
<p><a href="bugs.html">Daniel Veillard</a></p> <p><a href="bugs.html">Daniel Veillard</a></p>
</td></tr></table></td></tr></table></td></tr></table></td> </td></tr></table></td></tr></table></td></tr></table></td>
</tr></table></td></tr></table> </tr></table></td></tr></table>

View File

@@ -1 +0,0 @@
Unimplemented block at xmlschemastypes.c:1144

View File

@@ -1,2 +0,0 @@
Unimplemented block at xmlschemastypes.c:1141
Unimplemented block at xmlschemastypes.c:1141

View File

@@ -1,2 +0,0 @@
Unimplemented block at xmlschemastypes.c:1138
Unimplemented block at xmlschemastypes.c:1138

View File

@@ -1,4 +1,3 @@
Unimplemented block at xmlschemastypes.c:1138
error detected at relaxng.c:4164 error detected at relaxng.c:4164
error detected at relaxng.c:5255 error detected at relaxng.c:5255
error detected at relaxng.c:5053 error detected at relaxng.c:5053

View File

@@ -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:4353
error detected at relaxng.c:5255 error detected at relaxng.c:5255
error detected at relaxng.c:5053 error detected at relaxng.c:5053

View File

@@ -1,2 +0,0 @@
Unimplemented block at xmlschemastypes.c:1138
Unimplemented block at xmlschemastypes.c:1138

View File

@@ -1 +0,0 @@
Unimplemented block at xmlschemastypes.c:1141

View File

@@ -1,3 +0,0 @@
Unimplemented block at xmlschemastypes.c:1141
Unimplemented block at xmlschemastypes.c:1141
Unimplemented block at xmlschemastypes.c:1141

View File

@@ -1,2 +0,0 @@
Unimplemented block at xmlschemastypes.c:1141
Unimplemented block at xmlschemastypes.c:1141

View File

@@ -1,2 +0,0 @@
Unimplemented block at xmlschemastypes.c:1141
Unimplemented block at xmlschemastypes.c:1141

View File

@@ -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

View File

@@ -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

View File

@@ -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:4353
error detected at relaxng.c:5255 error detected at relaxng.c:5255
error detected at relaxng.c:5053 error detected at relaxng.c:5053

View File

@@ -1,4 +1,3 @@
Unimplemented block at xmlschemastypes.c:1141
error detected at relaxng.c:4164 error detected at relaxng.c:4164
error detected at relaxng.c:5255 error detected at relaxng.c:5255
error detected at relaxng.c:5053 error detected at relaxng.c:5053

View File

@@ -18,6 +18,8 @@
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
#include <libxml/hash.h> #include <libxml/hash.h>
#include <libxml/valid.h> #include <libxml/valid.h>
#include <libxml/xpath.h>
#include <libxml/uri.h>
#include <libxml/xmlschemas.h> #include <libxml/xmlschemas.h>
#include <libxml/schemasInternals.h> #include <libxml/schemasInternals.h>
@@ -53,6 +55,7 @@ typedef enum {
XML_SCHEMAS_DURATION, XML_SCHEMAS_DURATION,
XML_SCHEMAS_FLOAT, XML_SCHEMAS_FLOAT,
XML_SCHEMAS_DOUBLE, XML_SCHEMAS_DOUBLE,
XML_SCHEMAS_INT,
XML_SCHEMAS_, XML_SCHEMAS_,
XML_SCHEMAS_XXX XML_SCHEMAS_XXX
} xmlSchemaValType; } xmlSchemaValType;
@@ -129,6 +132,7 @@ static xmlSchemaTypePtr xmlSchemaTypeDurationDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL; static xmlSchemaTypePtr xmlSchemaTypeNmtoken = NULL;
static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeFloatDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeDoubleDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeNameDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeQNameDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeQNameDef = NULL;
static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL; static xmlSchemaTypePtr xmlSchemaTypeAnyURIDef = NULL;
@@ -205,6 +209,7 @@ xmlSchemaInitTypes(void) {
xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN"); xmlSchemaTypeNmtoken = xmlSchemaInitBasicType("NMTOKEN");
xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float"); xmlSchemaTypeFloatDef = xmlSchemaInitBasicType("float");
xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double"); xmlSchemaTypeDoubleDef = xmlSchemaInitBasicType("double");
xmlSchemaTypeNameDef = xmlSchemaInitBasicType("Name");
xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName"); xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName");
xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI"); xmlSchemaTypeAnyURIDef = xmlSchemaInitBasicType("anyURI");
@@ -965,6 +970,137 @@ error:
return 1; 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: * xmlSchemaValidatePredefinedType:
* @type: the predefined type * @type: the predefined type
@@ -981,6 +1117,7 @@ int
xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
xmlSchemaValPtr *val) { xmlSchemaValPtr *val) {
xmlSchemaValPtr v; xmlSchemaValPtr v;
int ret;
if (xmlSchemaTypesInitialized == 0) if (xmlSchemaTypesInitialized == 0)
return(-1); return(-1);
@@ -1108,42 +1245,195 @@ xmlSchemaValidatePredefinedType(xmlSchemaTypePtr type, const xmlChar *value,
} }
} }
return(0); return(0);
} else if (type == xmlSchemaTypeFloatDef) { } else if (type == xmlSchemaTypeIntDef) {
const xmlChar *cur = value, *tmp; const xmlChar *cur = value;
int frac = 0, len, neg = 0;
unsigned long base = 0; unsigned long base = 0;
int total = 0;
int sign = 0;
if (cur == NULL) if (cur == NULL)
return(1); 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 == '+') if (*cur == '+')
cur++; cur++;
else if (*cur == '-') { else if (*cur == '-') {
neg = 1; neg = 1;
cur++; 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')) { while ((*cur >= '0') && (*cur <= '9')) {
base = base * 10 + (*cur - '0');
cur++; cur++;
} }
len = cur - tmp;
if (*cur == '.') { if (*cur == '.') {
cur++; cur++;
tmp = cur; while ((*cur >= '0') && (*cur <= '9'))
while ((*cur >= '0') && (*cur <= '9')) {
base = base * 10 + (*cur - '0');
cur++; cur++;
} }
frac = cur - tmp; 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);
}
}
} }
TODO
return(0); return(0);
} else if (type == xmlSchemaTypeDoubleDef) { } else if (type == xmlSchemaTypeNameDef) {
TODO 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); return(0);
} else { } else {
TODO TODO
return(0); return(0);
} }
return(-1);
} }
/** /**