mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
more XML Schemas fixes based on Eric van der Vlist examples added
* xmlregexp.c xmlschemas.c: more XML Schemas fixes based on Eric van der Vlist examples * result/schemas/vdv-first4* test/schemas/vdv-first4*: added regression tests * doc/examples/Makefile.am doc/examples/index.py: do not regenerate the index on make all target, but only on make rebuild to avoid troubles. Daniel
This commit is contained in:
parent
be9c6320d4
commit
f2a1283564
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
Mon Nov 24 14:01:57 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xmlregexp.c xmlschemas.c: more XML Schemas fixes based
|
||||
on Eric van der Vlist examples
|
||||
* result/schemas/vdv-first4* test/schemas/vdv-first4*:
|
||||
added regression tests
|
||||
* doc/examples/Makefile.am doc/examples/index.py: do not
|
||||
regenerate the index on make all target, but only on
|
||||
make rebuild to avoid troubles.
|
||||
|
||||
Sat Nov 22 21:35:42 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xmlschemas.c xmlschemastypes.c include/libxml/xmlerror.h
|
||||
|
@ -7,7 +7,7 @@ INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAG
|
||||
DEPS = $(top_builddir)/libxml2.la
|
||||
LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
|
||||
|
||||
all: examples.xml index.html
|
||||
rebuild: examples.xml index.html
|
||||
|
||||
examples.xml: index.py *.c
|
||||
-@($(srcdir)/index.py)
|
||||
|
@ -227,7 +227,7 @@ INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAG
|
||||
DEPS = $(top_builddir)/libxml2.la
|
||||
LDADDS = @STATIC_BINARIES@ $(top_builddir)/libxml2.la @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) -lm @WIN32_EXTRA_LIBADD@
|
||||
|
||||
all: examples.xml index.html
|
||||
rebuild: examples.xml index.html
|
||||
|
||||
examples.xml: index.py *.c
|
||||
-@($(srcdir)/index.py)
|
||||
|
1
result/schemas/vdv-first4_0_0
Normal file
1
result/schemas/vdv-first4_0_0
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/vdv-first4_0.xml validates
|
0
result/schemas/vdv-first4_0_0.err
Normal file
0
result/schemas/vdv-first4_0_0.err
Normal file
1
result/schemas/vdv-first4_0_1
Normal file
1
result/schemas/vdv-first4_0_1
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/vdv-first4_1.xml fails to validate
|
1
result/schemas/vdv-first4_0_1.err
Normal file
1
result/schemas/vdv-first4_0_1.err
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/vdv-first4_1.xml:14: element born: Schemas validity error : Failed to validate basic type date
|
1
result/schemas/vdv-first4_0_2
Normal file
1
result/schemas/vdv-first4_0_2
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/vdv-first4_2.xml fails to validate
|
1
result/schemas/vdv-first4_0_2.err
Normal file
1
result/schemas/vdv-first4_0_2.err
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/vdv-first4_2.xml:24: element born: Schemas validity error : Failed to validate type with facet pattern
|
33
test/schemas/vdv-first4_0.xml
Normal file
33
test/schemas/vdv-first4_0.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- $Header: /cvs/gnome/gnome-xml/test/schemas/vdv-first3_0.xml,v 1.1 2003/11/22 20:37:51 veillard Exp $ -->
|
||||
<library>
|
||||
<book id="b0836217462" available="true">
|
||||
<isbn>0836217462</isbn>
|
||||
<title lang="en">Being a Dog Is a Full-Time Job</title>
|
||||
<author id="CMS">
|
||||
<name>Charles M Schulz</name>
|
||||
<born>1922-11-26</born>
|
||||
<dead>2000-02-12</dead>
|
||||
</author>
|
||||
<character id="PP">
|
||||
<name>Peppermint Patty</name>
|
||||
<born>1966-08-22</born>
|
||||
<qualification>bold, brash and tomboyish</qualification>
|
||||
</character>
|
||||
<character id="Snoopy">
|
||||
<name>Snoopy</name>
|
||||
<born>1950-10-04</born>
|
||||
<qualification>extroverted beagle</qualification>
|
||||
</character>
|
||||
<character id="Schroeder">
|
||||
<name>Schroeder</name>
|
||||
<born>1951-05-30</born>
|
||||
<qualification>brought classical music to the Peanuts strip</qualification>
|
||||
</character>
|
||||
<character id="Lucy">
|
||||
<name>Lucy</name>
|
||||
<born>1952-03-03</born>
|
||||
<qualification>bossy, crabby and selfish</qualification>
|
||||
</character>
|
||||
</book>
|
||||
</library>
|
150
test/schemas/vdv-first4_0.xsd
Executable file
150
test/schemas/vdv-first4_0.xsd
Executable file
@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first-complex-types.xsd,v 1.1 2001/11/12 20:54:00 vdv Exp $ -->
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<xs:simpleType name="string255">
|
||||
<xs:restriction base="xs:token">
|
||||
<xs:maxLength value="255"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="string32">
|
||||
<xs:restriction base="xs:token">
|
||||
<xs:maxLength value="32"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="isbn">
|
||||
<xs:restriction base="xs:unsignedLong">
|
||||
<xs:totalDigits value="10"/>
|
||||
<xs:pattern value="\d{10}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="bookID">
|
||||
<xs:restriction base="xs:ID">
|
||||
<xs:pattern value="b\d{10}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="supportedLanguages">
|
||||
<xs:restriction base="xs:language">
|
||||
<xs:enumeration value="en"/>
|
||||
<xs:enumeration value="es"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="date">
|
||||
<xs:restriction base="xs:date">
|
||||
<xs:pattern value="[^:Z]*"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:element name="name" type="string32"/>
|
||||
<xs:element name="qualification" type="string255"/>
|
||||
<xs:element name="born" type="date"/>
|
||||
<xs:element name="dead" type="date"/>
|
||||
<xs:element name="isbn" type="isbn"/>
|
||||
|
||||
<xs:attribute name="id" type="xs:ID"/>
|
||||
<xs:attribute name="available" type="xs:boolean"/>
|
||||
<xs:attribute name="lang" type="supportedLanguages"/>
|
||||
|
||||
<xs:complexType name="elementWithID">
|
||||
<xs:attribute ref="id"/>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="bookTmp">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="elementWithID">
|
||||
<xs:sequence>
|
||||
<xs:element ref="isbn"/>
|
||||
<xs:element ref="title"/>
|
||||
<xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="character" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute ref="available"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="personType">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="elementWithID">
|
||||
<xs:sequence>
|
||||
<xs:element ref="name"/>
|
||||
<xs:element ref="born"/>
|
||||
<xs:element ref="dead" minOccurs="0"/>
|
||||
<xs:element ref="qualification" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:element name="title">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="string255">
|
||||
<xs:attribute ref="lang"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="library">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="book" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="book">
|
||||
<xs:complexType>
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="bookTmp">
|
||||
<xs:sequence>
|
||||
<xs:element ref="isbn"/>
|
||||
<xs:element ref="title"/>
|
||||
<xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element ref="character" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="bookID"/>
|
||||
<xs:attribute ref="available"/>
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="author">
|
||||
<xs:complexType>
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="personType">
|
||||
<xs:sequence>
|
||||
<xs:element ref="name"/>
|
||||
<xs:element ref="born"/>
|
||||
<xs:element ref="dead" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute ref="id"/>
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
|
||||
<xs:element name="character">
|
||||
<xs:complexType>
|
||||
<xs:complexContent>
|
||||
<xs:restriction base="personType">
|
||||
<xs:sequence>
|
||||
<xs:element ref="name"/>
|
||||
<xs:element ref="born"/>
|
||||
<xs:element ref="qualification"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute ref="id"/>
|
||||
</xs:restriction>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
</xs:schema>
|
33
test/schemas/vdv-first4_1.xml
Normal file
33
test/schemas/vdv-first4_1.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- $Header: /cvs/gnome/gnome-xml/test/schemas/vdv-first3_0.xml,v 1.1 2003/11/22 20:37:51 veillard Exp $ -->
|
||||
<library>
|
||||
<book id="b0836217462" available="true">
|
||||
<isbn>0836217462</isbn>
|
||||
<title lang="en">Being a Dog Is a Full-Time Job</title>
|
||||
<author id="CMS">
|
||||
<name>Charles M Schulz</name>
|
||||
<born>1922-11-26</born>
|
||||
<dead>2000-02-12</dead>
|
||||
</author>
|
||||
<character id="PP">
|
||||
<name>Peppermint Patty</name>
|
||||
<born>196T6-08-22</born>
|
||||
<qualification>bold, brash and tomboyish</qualification>
|
||||
</character>
|
||||
<character id="Snoopy">
|
||||
<name>Snoopy</name>
|
||||
<born>1950-10-04</born>
|
||||
<qualification>extroverted beagle</qualification>
|
||||
</character>
|
||||
<character id="Schroeder">
|
||||
<name>Schroeder</name>
|
||||
<born>1951-05-30</born>
|
||||
<qualification>brought classical music to the Peanuts strip</qualification>
|
||||
</character>
|
||||
<character id="Lucy">
|
||||
<name>Lucy</name>
|
||||
<born>1952-03-03</born>
|
||||
<qualification>bossy, crabby and selfish</qualification>
|
||||
</character>
|
||||
</book>
|
||||
</library>
|
33
test/schemas/vdv-first4_2.xml
Normal file
33
test/schemas/vdv-first4_2.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- $Header: /cvs/gnome/gnome-xml/test/schemas/vdv-first3_0.xml,v 1.1 2003/11/22 20:37:51 veillard Exp $ -->
|
||||
<library>
|
||||
<book id="b0836217462" available="true">
|
||||
<isbn>0836217462</isbn>
|
||||
<title lang="en">Being a Dog Is a Full-Time Job</title>
|
||||
<author id="CMS">
|
||||
<name>Charles M Schulz</name>
|
||||
<born>1922-11-26</born>
|
||||
<dead>2000-02-12</dead>
|
||||
</author>
|
||||
<character id="PP">
|
||||
<name>Peppermint Patty</name>
|
||||
<born>1966-08-22</born>
|
||||
<qualification>bold, brash and tomboyish</qualification>
|
||||
</character>
|
||||
<character id="Snoopy">
|
||||
<name>Snoopy</name>
|
||||
<born>1950-10-04</born>
|
||||
<qualification>extroverted beagle</qualification>
|
||||
</character>
|
||||
<character id="Schroeder">
|
||||
<name>Schroeder</name>
|
||||
<born>2000-01-20Z</born>
|
||||
<qualification>brought classical music to the Peanuts strip</qualification>
|
||||
</character>
|
||||
<character id="Lucy">
|
||||
<name>Lucy</name>
|
||||
<born>1952-03-03</born>
|
||||
<qualification>bossy, crabby and selfish</qualification>
|
||||
</character>
|
||||
</book>
|
||||
</library>
|
@ -1992,6 +1992,7 @@ xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint) {
|
||||
return(codepoint == atom->codepoint);
|
||||
case XML_REGEXP_RANGES: {
|
||||
int accept = 0;
|
||||
|
||||
for (i = 0;i < atom->nbRanges;i++) {
|
||||
range = atom->ranges[i];
|
||||
if (range->neg) {
|
||||
@ -2000,6 +2001,8 @@ xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint) {
|
||||
range->blockName);
|
||||
if (ret != 0)
|
||||
return(0); /* excluded char */
|
||||
else
|
||||
accept = 1;
|
||||
} else {
|
||||
ret = xmlRegCheckCharacterRange(range->type, codepoint,
|
||||
0, range->start, range->end,
|
||||
@ -2199,6 +2202,8 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
exec->state = comp->states[0];
|
||||
exec->transno = 0;
|
||||
exec->transcount = 0;
|
||||
exec->inputStack = NULL;
|
||||
exec->inputStackMax = 0;
|
||||
if (comp->nbCounters > 0) {
|
||||
exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int));
|
||||
if (exec->counts == NULL) {
|
||||
|
60
xmlschemas.c
60
xmlschemas.c
@ -933,6 +933,7 @@ xmlSchemaGetNamespace(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
* @schema: the schemas context
|
||||
* @name: the element name
|
||||
* @ns: the element namespace
|
||||
* @level: how deep is the request
|
||||
*
|
||||
* Lookup a an element in the schemas or the accessible schemas
|
||||
*
|
||||
@ -940,33 +941,40 @@ xmlSchemaGetNamespace(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
*/
|
||||
static xmlSchemaElementPtr
|
||||
xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name,
|
||||
const xmlChar * namespace)
|
||||
const xmlChar * namespace, int level)
|
||||
{
|
||||
xmlSchemaElementPtr ret;
|
||||
xmlSchemaImportPtr import;
|
||||
xmlSchemaImportPtr import = NULL;
|
||||
|
||||
if ((name == NULL) || (schema == NULL))
|
||||
return (NULL);
|
||||
|
||||
if (namespace == NULL) {
|
||||
ret = xmlHashLookup2(schema->elemDecl, name, namespace);
|
||||
if (ret != NULL)
|
||||
if ((ret != NULL) &&
|
||||
((level == 0) || (ret->flags & XML_SCHEMAS_ELEM_TOPLEVEL))) {
|
||||
return (ret);
|
||||
}
|
||||
} else if ((schema->flags & XML_SCHEMAS_QUALIF_ELEM) == 0) {
|
||||
if (xmlStrEqual(namespace, schema->targetNamespace))
|
||||
ret = xmlHashLookup2(schema->elemDecl, name, NULL);
|
||||
else
|
||||
ret = xmlHashLookup2(schema->elemDecl, name, namespace);
|
||||
if (ret != NULL)
|
||||
if ((ret != NULL) &&
|
||||
((level == 0) || (ret->flags & XML_SCHEMAS_ELEM_TOPLEVEL))) {
|
||||
return (ret);
|
||||
}
|
||||
} else {
|
||||
ret = xmlHashLookup2(schema->elemDecl, name, namespace);
|
||||
if (ret != NULL)
|
||||
if ((ret != NULL) &&
|
||||
((level == 0) || (ret->flags & XML_SCHEMAS_ELEM_TOPLEVEL))) {
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
if (level > 0)
|
||||
import = xmlHashLookup(schema->schemasImports, namespace);
|
||||
if (import != NULL)
|
||||
ret = xmlSchemaGetElem(import->schema, name, namespace);
|
||||
ret = xmlSchemaGetElem(import->schema, name, namespace, level + 1);
|
||||
#ifdef DEBUG
|
||||
if (ret == NULL) {
|
||||
if (namespace == NULL)
|
||||
@ -3947,7 +3955,7 @@ xmlSchemaRefFixupCallback(xmlSchemaElementPtr elem,
|
||||
name, NULL);
|
||||
return;
|
||||
}
|
||||
elemDecl = xmlSchemaGetElem(ctxt->schema, elem->ref, elem->refNs);
|
||||
elemDecl = xmlSchemaGetElem(ctxt->schema, elem->ref, elem->refNs, 0);
|
||||
|
||||
if (elemDecl == NULL) {
|
||||
xmlSchemaPErr(ctxt, elem->node, XML_SCHEMAP_UNKNOWN_REF,
|
||||
@ -4123,6 +4131,9 @@ xmlSchemaTypeFixup(xmlSchemaTypePtr typeDecl,
|
||||
typeDecl->contentType =
|
||||
typeDecl->subtypes->contentType;
|
||||
}
|
||||
if (typeDecl->attributes == NULL)
|
||||
typeDecl->attributes =
|
||||
typeDecl->subtypes->attributes;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4140,6 +4151,9 @@ xmlSchemaTypeFixup(xmlSchemaTypePtr typeDecl,
|
||||
typeDecl->contentType =
|
||||
typeDecl->subtypes->contentType;
|
||||
}
|
||||
if (typeDecl->attributes == NULL)
|
||||
typeDecl->attributes =
|
||||
typeDecl->subtypes->attributes;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4613,6 +4627,17 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
|
||||
xmlHashScanFull(ret->elemDecl,
|
||||
(xmlHashScannerFull) xmlSchemaRefFixupCallback, ctxt);
|
||||
|
||||
/*
|
||||
* Then fixup all attributes declarations
|
||||
*/
|
||||
xmlHashScan(ret->attrDecl, (xmlHashScanner) xmlSchemaAttrFixup, ctxt);
|
||||
|
||||
/*
|
||||
* Then fixup all attributes group declarations
|
||||
*/
|
||||
xmlHashScan(ret->attrgrpDecl, (xmlHashScanner) xmlSchemaAttrGrpFixup,
|
||||
ctxt);
|
||||
|
||||
/*
|
||||
* Then fixup all types properties
|
||||
*/
|
||||
@ -4630,17 +4655,6 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
|
||||
xmlHashScan(ret->typeDecl, (xmlHashScanner) xmlSchemaCheckDefaults,
|
||||
ctxt);
|
||||
|
||||
/*
|
||||
* Then fixup all attributes declarations
|
||||
*/
|
||||
xmlHashScan(ret->attrDecl, (xmlHashScanner) xmlSchemaAttrFixup, ctxt);
|
||||
|
||||
/*
|
||||
* Then fixup all attributes group declarations
|
||||
*/
|
||||
xmlHashScan(ret->attrgrpDecl, (xmlHashScanner) xmlSchemaAttrGrpFixup,
|
||||
ctxt);
|
||||
|
||||
if (ctxt->nberrors != 0) {
|
||||
xmlSchemaFree(ret);
|
||||
ret = NULL;
|
||||
@ -4815,7 +4829,8 @@ xmlSchemaValidateSimpleValue(xmlSchemaValidCtxtPtr ctxt,
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not validate facets when working on building the Schemas
|
||||
* Do not validate facets or attributes when working on
|
||||
* building the Schemas
|
||||
*/
|
||||
if (ctxt->schema != NULL) {
|
||||
if (ret == 0) {
|
||||
@ -4991,6 +5006,10 @@ xmlSchemaValidateSimpleContent(xmlSchemaValidCtxtPtr ctxt,
|
||||
ret =
|
||||
xmlSchemaValidateFacets(ctxt, base, facet, value);
|
||||
}
|
||||
if ((ret == 0) && (type->attributes != NULL)) {
|
||||
ret = xmlSchemaValidateAttributes(ctxt, node,
|
||||
type->attributes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XML_SCHEMA_TYPE_EXTENSION:{
|
||||
@ -5445,6 +5464,9 @@ xmlSchemaValidateComplexType(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr node)
|
||||
*/
|
||||
child = xmlSchemaSkipIgnored(ctxt, type, child);
|
||||
}
|
||||
if (type->attributes != NULL) {
|
||||
xmlSchemaValidateAttributes(ctxt, node, type->attributes);
|
||||
}
|
||||
break;
|
||||
case XML_SCHEMA_CONTENT_BASIC:{
|
||||
if (type->subtypes != NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user