Commit 91a1325b authored by Daniel Veillard's avatar Daniel Veillard

fixed bugs and memory leaks in the W3C XML Schemas code implemented

* xmlschemas.c include/libxml/xmlschemas.h: fixed bugs and memory
  leaks in the W3C XML Schemas code
* xmlschemastypes.c: implemented nonPositiveInteger
* test/schemas/length2_0.xsd result/schemas/length2_0_0.err:
  fixed the test and result.
Daniel
parent 6560a42c
Fri Mar 28 00:41:55 CET 2003 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c include/libxml/xmlschemas.h: fixed bugs and memory
leaks in the W3C XML Schemas code
* xmlschemastypes.c: implemented nonPositiveInteger
* test/schemas/length2_0.xsd result/schemas/length2_0_0.err:
fixed the test and result.
Thu Mar 27 22:23:07 CET 2003 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c tree.c: two patches from James Bursa on the HTML
......
......@@ -44,6 +44,7 @@ typedef enum {
XML_SCHEMAS_ERR_NOTSIMPLE,
XML_SCHEMAS_ERR_ATTRUNKNOWN,
XML_SCHEMAS_ERR_ATTRINVALID,
XML_SCHEMAS_ERR_VALUE,
XML_SCHEMAS_ERR_,
XML_SCHEMAS_ERR_XXX
} xmlSchemaValidError;
......
Unable to lookup type nonPositiveInteger:http://www.w3.org/2001/XMLSchemaSchemas: element size type nonPositiveInteger not found
Type of sequence 3 : ./test/schemas/length2_0.xsd:6 :elements
Type of restriction 2 : ./test/schemas/length2_0.xsd:5 :elements
Type of complexContent 1 : ./test/schemas/length2_0.xsd:4 :elements
......
......@@ -4,7 +4,7 @@
<xs:complexContent>
<xs:restriction base="xs:anyType">
<xs:sequence>
<xs:element name="size" type="xs:nonPositiveInteger"/>
<xs:element name="size" type="xs:nonNegativeInteger"/>
<xs:element name="unit" type="xs:NMTOKEN"/>
</xs:sequence>
</xs:restriction>
......
......@@ -278,6 +278,10 @@ xmlSchemaFreeAttributeGroup(xmlSchemaAttributeGroupPtr attr)
return;
if (attr->name != NULL)
xmlFree((xmlChar *) attr->name);
if (attr->ref != NULL)
xmlFree((xmlChar *) attr->ref);
if (attr->refNs != NULL)
xmlFree((xmlChar *) attr->refNs);
xmlFree(attr);
}
......@@ -377,6 +381,10 @@ xmlSchemaFree(xmlSchemaPtr schema)
if (schema == NULL)
return;
if (schema->id != NULL)
xmlFree((xmlChar *) schema->id);
if (schema->targetNamespace != NULL)
xmlFree((xmlChar *) schema->targetNamespace);
if (schema->name != NULL)
xmlFree((xmlChar *) schema->name);
if (schema->notaDecl != NULL)
......@@ -1661,6 +1669,12 @@ xmlSchemaParseAttributeGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
snprintf(buf, 99, "anonattrgroup%d", ctxt->counter++ + 1);
name = xmlStrdup((xmlChar *) buf);
if (name == NULL) {
if ((ctxt != NULL) && (ctxt->error != NULL))
ctxt->error(ctxt->userData,
"out of memory\n");
return (NULL);
}
}
ret = xmlSchemaAddAttributeGroup(ctxt, schema, name);
if (ret == NULL) {
......@@ -1711,6 +1725,7 @@ xmlSchemaParseAttributeGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
ctxt->container = oldcontainer;
xmlFree(name);
return (ret);
}
......@@ -4841,6 +4856,7 @@ xmlSchemaValidateBasicType(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr node) {
ctxt->error(ctxt->userData,
"Element %s: failed to validate basic type %s\n",
node->name, type->name);
ctxt->err = XML_SCHEMAS_ERR_VALUE;
}
return(ret);
}
......
......@@ -1286,8 +1286,7 @@ xmlSchemaValPredefTypeNode(xmlSchemaTypePtr type, const xmlChar *value,
if (*cur == '-') {
sign = 1;
cur++;
} else if (*cur == '+')
cur++;
}
while ((*cur >= '0') && (*cur <= '9')) {
base = base * 10 + (*cur - '0');
total++;
......@@ -1308,6 +1307,37 @@ xmlSchemaValPredefTypeNode(xmlSchemaTypePtr type, const xmlChar *value,
}
}
return(0);
} else if (type == xmlSchemaTypeNonPositiveIntegerDef) {
const xmlChar *cur = value;
unsigned long base = 0;
int total = 0;
int sign = 0;
if (cur == NULL)
return(1);
if (*cur == '-') {
sign = 1;
cur++;
}
while ((*cur >= '0') && (*cur <= '9')) {
base = base * 10 + (*cur - '0');
total++;
cur++;
}
if (*cur != 0)
return(1);
if ((sign != 1) && (base != 0))
return(1);
if (val != NULL) {
v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL);
if (v != NULL) {
v->value.decimal.base = base;
v->value.decimal.sign = 0;
v->value.decimal.frac = 0;
v->value.decimal.total = total;
*val = v;
}
}
return(0);
} else if (type == xmlSchemaTypeIntDef) {
const xmlChar *cur = value;
unsigned long base = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment