Commit 3646d646 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

applied a patch from Kasimier Buchcik implementing attribute uses and

* xmlschemas.c include/libxml/schemasInternals.h
  include/libxml/xmlerror.h: applied a patch from Kasimier Buchcik
  implementing attribute uses and wildcards.
* test/schemas/* result/schemas/*: added/fixed a bunch of tests
Daniel
parent 0335a846
Wed Jun 2 21:16:26 CEST 2004 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c include/libxml/schemasInternals.h
include/libxml/xmlerror.h: applied a patch from Kasimier Buchcik
implementing attribute uses and wildcards.
* test/schemas/* result/schemas/*: added/fixed a bunch of tests
Wed Jun 2 18:15:51 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
* globals.c xmlIO.c include/libxml/globals.h: applied patch from
......
......@@ -112,27 +112,48 @@ struct _xmlSchemaAnnot {
* Apply strict validation rules on attributes
*/
#define XML_SCHEMAS_ANYATTR_STRICT 3
/**
* XML_SCHEMAS_ANY_SKIP:
*
* Skip unknown attribute from validation
*/
#define XML_SCHEMAS_ANY_SKIP 1
/**
* XML_SCHEMAS_ANY_LAX:
*
* Ignore validation non definition on attributes
*/
#define XML_SCHEMAS_ANY_LAX 2
/**
* XML_SCHEMAS_ANY_STRICT:
*
* Apply strict validation rules on attributes
*/
#define XML_SCHEMAS_ANY_STRICT 3
/**
* XML_SCHEMAS_ATTR_USE_PROHIBITED:
*
* The attribute is prohibited.
*/
#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0
/**
* XML_SCHEMAS_ATTR_USE_REQUIRED:
*
* The attribute is required.
*/
#define XML_SCHEMAS_ATTR_USE_REQUIRED 1
/**
* XML_SCHEMAS_ATTR_USE_OPTIONAL:
*
* The attribute is optional.
*/
#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2
/**
* XML_SCHEMAS_ATTR_GLOABAL:
*
* allow elements in no namespace
*/
#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0
/**
* XML_SCHEMAS_ATTR_NSDEFAULT:
......@@ -168,6 +189,68 @@ struct _xmlSchemaAttribute {
int flags;
};
/**
* xmlSchemaAttributeLink:
* Used to build a list of attribute uses on complexType definitions.
*/
typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;
typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;
struct _xmlSchemaAttributeLink {
struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */
struct _xmlSchemaAttribute *attr;/* the linked attribute */
};
/**
* XML_SCHEMAS_WILDCARD_COMPLETE:
*
* If the wildcard is complete.
*/
#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0
/**
* xmlSchemaCharValueLink:
* Used to build a list of namespaces on wildcards.
*/
typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;
typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;
struct _xmlSchemaWildcardNs {
struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */
const xmlChar *value;/* the value */
};
/**
* xmlSchemaWildcard.
* A wildcard.
*/
typedef struct _xmlSchemaWildcard xmlSchemaWildcard;
typedef xmlSchemaWildcard *xmlSchemaWildcardPtr;
struct _xmlSchemaWildcard {
xmlSchemaTypeType type; /* The kind of type */
const xmlChar *id;
xmlSchemaAnnotPtr annot;
xmlNodePtr node;
int minOccurs;
int maxOccurs;
int processContents;
int any; /* Indicates if the ns constraint is of ##any */
xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */
xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */
int flags;
};
/**
* XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:
*
* The attribute wildcard has been already builded.
*/
#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0
/**
* XML_SCHEMAS_ATTRGROUP_GLOBAL:
*
* The attribute wildcard has been already builded.
*/
#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1
/**
* An attribute group definition.
*
......@@ -187,6 +270,8 @@ struct _xmlSchemaAttributeGroup {
xmlSchemaAttributePtr attributes;
xmlNodePtr node;
int flags;
xmlSchemaWildcardPtr attributeWildcard;
};
......@@ -196,6 +281,31 @@ struct _xmlSchemaAttributeGroup {
* the element content type is mixed
*/
#define XML_SCHEMAS_TYPE_MIXED 1 << 0
/**
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:
*
* the simple or complex type has a derivation method of "extension".
*/
#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1
/**
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:
*
* the simple or complex type has a derivation method of "restriction".
*/
#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2
/**
* XML_SCHEMAS_TYPE_GLOBAL:
*
* the type is global
*/
#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3
/**
* XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:
*
* the complexType owns an attribute wildcard, i.e.
* it can be freed by the complexType
*/
#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4
/**
* _xmlSchemaType:
......@@ -224,6 +334,8 @@ struct _xmlSchemaType {
xmlSchemaFacetPtr facets;
struct _xmlSchemaType *redef;/* possible redefinitions for the type */
int recurse;
xmlSchemaAttributeLinkPtr attributeUses;
xmlSchemaWildcardPtr attributeWildcard;
};
/*
......@@ -267,6 +379,7 @@ struct _xmlSchemaType {
* XML_SCHEMAS_ELEM_TOPLEVEL:
*
* the element is top level
* obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead
*/
#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
/**
......@@ -414,4 +527,3 @@ XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
#endif /* LIBXML_SCHEMAS_ENABLED */
#endif /* __XML_SCHEMA_INTERNALS_H__ */
......@@ -555,6 +555,21 @@ typedef enum {
XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1778 */
XML_SCHEMAP_INVALID_ATTR_NAME, /* 1779 */
XML_SCHEMAP_REF_AND_CONTENT, /* 1780 */
XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1781 */
XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1782 */
XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1783 */
XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1784 */
XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1785 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1786 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1787 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1788 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1789 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1790 */
XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1791 */
XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1792 */
XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1793 */
XML_SCHRMAP_SRC_IMPORT_3_1, /* 1794 */
XML_SCHRMAP_SRC_IMPORT_3_2, /* 1795 */
XML_SCHEMAV_NOROOT = 1800,
XML_SCHEMAV_UNDECLAREDELEM, /* 1801 */
XML_SCHEMAV_NOTTOPLEVEL, /* 1802 */
......
./test/schemas/anyAttr-derive-errors1_0.xml validates
./test/schemas/anyAttr-derive1_0.xml validates
./test/schemas/anyAttr1_0.xml validates
./test/schemas/attruse_0_1.xml:3: element barA: Schemas validity error : required attribute attr on barA is missing
./test/schemas/attruse_0_1.xml:3: element barA: Schemas validity error : required attribute attr on barA is missing
./test/schemas/attruse_0_1.xml:3: element barA: Schemas validity error : required attribute attr on barA is missing
../test/schemas/attruse_0_1.xml:3: element barA: Schemas validity error : Attribute attr on barA is required but missing
./test/schemas/attruse_0_2.xml:6: element barC: Schemas validity error : attribute attr on barC is prohibited
./test/schemas/attruse_0_2.xml:6: element barC: Schemas validity error : attribute attr on barC is prohibited
./test/schemas/attruse_0_2.xml:6: element barC: Schemas validity error : attribute attr on barC is prohibited
../test/schemas/attruse_0_2.xml:6: element barC: Schemas validity error : Attribute attr on barC is unknown
./test/schemas/derivation-ok-extension-err_0.xsd:17: element attribute: Schemas parser error : ct-props-correct.4: Duplicate attribute use with the name "barA_1" specified
./test/schemas/derivation-ok-extension_0.xsd:17: element attribute: Schemas parser error : ct-props-correct.4: Duplicate attribute use with the name "barA_1" specified
./test/schemas/derivation-ok-restriction-2-1-1_0.xsd:16: element attribute: Schemas parser error : derivation-ok-restriction.2.1.1: The "optional" attribute use "barB_1" is inconsistent with a matching "required" attribute use of the base type
./test/schemas/derivation-ok-restriction-2-1-1_0.xsd:20: element attribute: Schemas parser error : derivation-ok-restriction.3: The "required" attribute use "barB_3" of the base type does not have a matching attribute use in the derived type
./test/schemas/derivation-ok-restriction-2-1-1_0.xsd:23: element attribute: Schemas parser error : derivation-ok-restriction.2.2: The attribute use "barC_1" has neither a matching attribute use, nor a matching wildcard in the base type
./test/schemas/derivation-ok-restriction-2-1-1_0.xsd:25: element attribute: Schemas parser error : derivation-ok-restriction.2.2: The attribute use "barC_2" has neither a matching attribute use, nor a matching wildcard in the base type
./test/schemas/derivation-ok-restriction-2-1-1_0.xsd:30: element attribute: Schemas parser error : derivation-ok-restriction.2.2: The attribute use "barD_1" has neither a matching attribute use, nor a matching wildcard in the base type
./test/schemas/derivation-ok-restriction-2-1-1_0.xsd:32: element attribute: Schemas parser error : derivation-ok-restriction.2.2: The attribute use "barD_2" has neither a matching attribute use, nor a matching wildcard in the base type
./test/schemas/derivation-restriction-anyAttr_0.xml validates
<?xml version="1.0" encoding="ISO-8859-1"?>
<foo
xmlns="http://FOO"
xmlns:foo="http://FOO"
xmlns:bar="http://BAR"
xmlns:doo="http://DOO"
xmlns:import="http://IMPORT"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://FOO anyAttr-derive-errors1_0.xsd">
<derive.1_1 barA="o" bar:barB="o" foo:barC="o"/>
<derive.1_4 barA="o" bar:barB="o" foo:barC="o"/>
<derive.2_1 barA="o" bar:barB="o" foo:barC="o" doo:barD="o" />
<derive.3_1 barA="o" foo:barC="o" doo:barD="o" />
<derive.4_1 bar:barB="o" foo:barC="o" doo:barD="o"/>
<derive.5_1_a barA="o" bar:barB="o" foo:barC="o" doo:barD="o" />
<derive.5_1_b barA="o" bar:barB="o" foo:barC="o" doo:barD="o" />
<derive.5_2_a bar:barB="o" foo:barC="o" doo:barD="o" />
<derive.5_2_b bar:barB="o" foo:barC="o" doo:barD="o" />
<derive.5_4_a bar:barB="o" doo:barD="o" />
<derive.5_4_b bar:barB="o" doo:barD="o" />
<derive.6_1 barA="o" bar:barB="o" foo:barC="o" doo:barD="o"/>
<derive.6_2 bar:barB="o" foo:barC="o" doo:barD="o"/>
</foo>
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