diff --git a/ChangeLog b/ChangeLog index fc7397d4..aee92b7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Nov 24 14:01:57 CET 2003 Daniel Veillard + + * 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 * xmlschemas.c xmlschemastypes.c include/libxml/xmlerror.h diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am index e90c867d..ebcf18e1 100644 --- a/doc/examples/Makefile.am +++ b/doc/examples/Makefile.am @@ -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) diff --git a/doc/examples/index.py b/doc/examples/index.py index c2235b88..8c64757c 100755 --- a/doc/examples/index.py +++ b/doc/examples/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) diff --git a/result/schemas/vdv-first4_0_0 b/result/schemas/vdv-first4_0_0 new file mode 100644 index 00000000..bfa9b29a --- /dev/null +++ b/result/schemas/vdv-first4_0_0 @@ -0,0 +1 @@ +./test/schemas/vdv-first4_0.xml validates diff --git a/result/schemas/vdv-first4_0_0.err b/result/schemas/vdv-first4_0_0.err new file mode 100644 index 00000000..e69de29b diff --git a/result/schemas/vdv-first4_0_1 b/result/schemas/vdv-first4_0_1 new file mode 100644 index 00000000..19a7ac14 --- /dev/null +++ b/result/schemas/vdv-first4_0_1 @@ -0,0 +1 @@ +./test/schemas/vdv-first4_1.xml fails to validate diff --git a/result/schemas/vdv-first4_0_1.err b/result/schemas/vdv-first4_0_1.err new file mode 100644 index 00000000..6eafb621 --- /dev/null +++ b/result/schemas/vdv-first4_0_1.err @@ -0,0 +1 @@ +./test/schemas/vdv-first4_1.xml:14: element born: Schemas validity error : Failed to validate basic type date diff --git a/result/schemas/vdv-first4_0_2 b/result/schemas/vdv-first4_0_2 new file mode 100644 index 00000000..fb59b67d --- /dev/null +++ b/result/schemas/vdv-first4_0_2 @@ -0,0 +1 @@ +./test/schemas/vdv-first4_2.xml fails to validate diff --git a/result/schemas/vdv-first4_0_2.err b/result/schemas/vdv-first4_0_2.err new file mode 100644 index 00000000..d37271a2 --- /dev/null +++ b/result/schemas/vdv-first4_0_2.err @@ -0,0 +1 @@ +./test/schemas/vdv-first4_2.xml:24: element born: Schemas validity error : Failed to validate type with facet pattern diff --git a/test/schemas/vdv-first4_0.xml b/test/schemas/vdv-first4_0.xml new file mode 100644 index 00000000..0b2d7e22 --- /dev/null +++ b/test/schemas/vdv-first4_0.xml @@ -0,0 +1,33 @@ + + + + + 0836217462 + Being a Dog Is a Full-Time Job + + Charles M Schulz + 1922-11-26 + 2000-02-12 + + + Peppermint Patty + 1966-08-22 + bold, brash and tomboyish + + + Snoopy + 1950-10-04 + extroverted beagle + + + Schroeder + 1951-05-30 + brought classical music to the Peanuts strip + + + Lucy + 1952-03-03 + bossy, crabby and selfish + + + diff --git a/test/schemas/vdv-first4_0.xsd b/test/schemas/vdv-first4_0.xsd new file mode 100755 index 00000000..9e8e2363 --- /dev/null +++ b/test/schemas/vdv-first4_0.xsd @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/schemas/vdv-first4_1.xml b/test/schemas/vdv-first4_1.xml new file mode 100644 index 00000000..1259ef2b --- /dev/null +++ b/test/schemas/vdv-first4_1.xml @@ -0,0 +1,33 @@ + + + + + 0836217462 + Being a Dog Is a Full-Time Job + + Charles M Schulz + 1922-11-26 + 2000-02-12 + + + Peppermint Patty + 196T6-08-22 + bold, brash and tomboyish + + + Snoopy + 1950-10-04 + extroverted beagle + + + Schroeder + 1951-05-30 + brought classical music to the Peanuts strip + + + Lucy + 1952-03-03 + bossy, crabby and selfish + + + diff --git a/test/schemas/vdv-first4_2.xml b/test/schemas/vdv-first4_2.xml new file mode 100644 index 00000000..c4acce60 --- /dev/null +++ b/test/schemas/vdv-first4_2.xml @@ -0,0 +1,33 @@ + + + + + 0836217462 + Being a Dog Is a Full-Time Job + + Charles M Schulz + 1922-11-26 + 2000-02-12 + + + Peppermint Patty + 1966-08-22 + bold, brash and tomboyish + + + Snoopy + 1950-10-04 + extroverted beagle + + + Schroeder + 2000-01-20Z + brought classical music to the Peanuts strip + + + Lucy + 1952-03-03 + bossy, crabby and selfish + + + diff --git a/xmlregexp.c b/xmlregexp.c index 0af5a7a3..c8d1ad13 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -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) { diff --git a/xmlschemas.c b/xmlschemas.c index 58a460eb..feafab9e 100644 --- a/xmlschemas.c +++ b/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) {