Commit 876a6db1 authored by Kasimier T. Buchcik's avatar Kasimier T. Buchcik
Browse files

Simpified attribute wildcard creation and assignment to get rid of memory

* xmlschemas.c include/libxml/schemasInternals.h
  test/schemas/bug152470_1.* result/schemas/bug152470_1_1*:
  Simpified attribute wildcard creation and assignment to get rid
  of memory leaks.
  Restructured the validation process.
  Restructured and expanded parsing of <attributeGroup>.
  Added initial handing of xsi:type.
  Advanced handling of xsi:nil (should work now for simple types).
  Added construction of schemata using xsi:schemaLocation and
  xsi:noNamespaceSchemaLocation; this is not enabled, since
  no corresponding API exists yet.
  Moved the content model to complex type components.
  Resolution of types for attributes will look for simple types
  only (incl. all the built-in simple types).
  Extended parsing of 'anyAttribute'.
  Fixed content-type type for complex types if derived from
  'anyType' using the short-hand form (see bug # 152470,
  submitted by Thilo Jeremias).
* include/libxml/xmlschematypes.h: Cleaned u...
parent 0046c2a1
Thu Sep 16 13:24:27 CEST 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c include/libxml/schemasInternals.h
test/schemas/bug152470_1.* result/schemas/bug152470_1_1*:
Simpified attribute wildcard creation and assignment to get rid
of memory leaks.
Restructured the validation process.
Restructured and expanded parsing of <attributeGroup>.
Added initial handing of xsi:type.
Advanced handling of xsi:nil (should work now for simple types).
Added construction of schemata using xsi:schemaLocation and
xsi:noNamespaceSchemaLocation; this is not enabled, since
no corresponding API exists yet.
Moved the content model to complex type components.
Resolution of types for attributes will look for simple types
only (incl. all the built-in simple types).
Extended parsing of 'anyAttribute'.
Fixed content-type type for complex types if derived from
'anyType' using the short-hand form (see bug # 152470,
submitted by Thilo Jeremias).
* include/libxml/xmlschematypes.h: Cleaned up some comments.
* xstc/xstc.py: Workaround to accomodate case insensitive
test definitions in ms-test.def.xml.
* result/schemas/deter0_0_0.err result/schemas/ns0_0_2.err
result/schemas/ns0_1_2.err: Adapted.
Sat Sep 11 09:04:22 PDT 2004 William Brack <wbrack@mmm.com.hk>
 
* xmlwriter.c: changed char array initialisation to avoid a
......
......@@ -44,15 +44,15 @@ typedef enum {
XML_SCHEMAS_TOKEN,
XML_SCHEMAS_LANGUAGE,
XML_SCHEMAS_NMTOKEN,
XML_SCHEMAS_NMTOKENS,
XML_SCHEMAS_NMTOKENS,
XML_SCHEMAS_NAME,
XML_SCHEMAS_QNAME,
XML_SCHEMAS_NCNAME,
XML_SCHEMAS_ID,
XML_SCHEMAS_IDREF,
XML_SCHEMAS_IDREFS,
XML_SCHEMAS_IDREFS,
XML_SCHEMAS_ENTITY,
XML_SCHEMAS_ENTITIES,
XML_SCHEMAS_ENTITIES,
XML_SCHEMAS_NOTATION,
XML_SCHEMAS_ANYURI,
XML_SCHEMAS_INTEGER,
......@@ -71,7 +71,7 @@ typedef enum {
XML_SCHEMAS_HEXBINARY,
XML_SCHEMAS_BASE64BINARY,
XML_SCHEMAS_ANYTYPE,
XML_SCHEMAS_ANYSIMPLETYPE
XML_SCHEMAS_ANYSIMPLETYPE
} xmlSchemaValType;
/*
......@@ -149,25 +149,25 @@ struct _xmlSchemaAnnot {
* Skip unknown attribute from validation
* Obsolete, not used anymore.
*/
#define XML_SCHEMAS_ANYATTR_SKIP 1
#define XML_SCHEMAS_ANYATTR_SKIP 1
/**
* XML_SCHEMAS_ANYATTR_LAX:
*
* Ignore validation non definition on attributes
* Obsolete, not used anymore.
*/
#define XML_SCHEMAS_ANYATTR_LAX 2
#define XML_SCHEMAS_ANYATTR_LAX 2
/**
* XML_SCHEMAS_ANYATTR_STRICT:
*
* Apply strict validation rules on attributes
* Obsolete, not used anymore.
*/
#define XML_SCHEMAS_ANYATTR_STRICT 3
#define XML_SCHEMAS_ANYATTR_STRICT 3
/**
* XML_SCHEMAS_ANY_SKIP:
*
* Skip unknown attribute from validation
* Skip unknown attribute from validation
*/
#define XML_SCHEMAS_ANY_SKIP 1
/**
......@@ -214,20 +214,20 @@ struct _xmlSchemaAnnot {
*
* allow elements in no namespace
*/
#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
/**
* XML_SCHEMAS_ATTR_NSDEFAULT:
*
* this is set when the "type" and "ref" references
* this is set when the "type" and "ref" references
* have been resolved.
*/
#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8
#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8
/**
* XML_SCHEMAS_ATTR_FIXED:
*
* the attribute has a fixed value
*/
#define XML_SCHEMAS_ATTR_FIXED 1 << 9
#define XML_SCHEMAS_ATTR_FIXED 1 << 9
/**
* xmlSchemaAttribute:
......@@ -237,8 +237,8 @@ struct _xmlSchemaAnnot {
typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
struct _xmlSchemaAttribute {
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
const xmlChar *name; /* name of the declaration or empty if particle */
const xmlChar *id;
const xmlChar *ref; /* the local name of the attribute decl. if a particle */
......@@ -252,7 +252,7 @@ struct _xmlSchemaAttribute {
const xmlChar *defValue;
xmlSchemaTypePtr subtypes; /* the type definition */
xmlNodePtr node;
const xmlChar *targetNamespace;
const xmlChar *targetNamespace;
int flags;
const xmlChar *refPrefix;
};
......@@ -334,7 +334,7 @@ struct _xmlSchemaWildcard {
typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
struct _xmlSchemaAttributeGroup {
xmlSchemaTypeType type; /* The kind of type */
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
const xmlChar *name;
const xmlChar *id;
......@@ -378,7 +378,7 @@ struct _xmlSchemaFacetLink {
*
* the element content type is mixed
*/
#define XML_SCHEMAS_TYPE_MIXED 1 << 0
#define XML_SCHEMAS_TYPE_MIXED 1 << 0
/**
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:
*
......@@ -469,7 +469,7 @@ struct _xmlSchemaFacetLink {
*
* Marks the item as marked; used for circular checks.
*/
#define XML_SCHEMAS_TYPE_MARKED 1 << 16
#define XML_SCHEMAS_TYPE_MARKED 1 << 16
/**
* _xmlSchemaType:
......@@ -477,7 +477,7 @@ struct _xmlSchemaFacetLink {
* Schemas type definition.
*/
struct _xmlSchemaType {
xmlSchemaTypeType type; /* The kind of type */
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaType *next;/* the next type if in a sequence ... */
const xmlChar *name;
const xmlChar *id;
......@@ -494,7 +494,7 @@ struct _xmlSchemaType {
xmlSchemaContentType contentType;
const xmlChar *base;
const xmlChar *baseNs;
xmlSchemaTypePtr baseType;
xmlSchemaTypePtr baseType;
xmlSchemaFacetPtr facets;
struct _xmlSchemaType *redef;/* possible redefinitions for the type */
int recurse;
......@@ -505,6 +505,7 @@ struct _xmlSchemaType {
xmlSchemaFacetLinkPtr facetSet;
const xmlChar *refPrefix;
xmlSchemaTypePtr contentTypeDef;
xmlRegexpPtr contModel;
};
/*
......@@ -519,112 +520,112 @@ struct _xmlSchemaType {
*
* the element is nillable
*/
#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
/**
* XML_SCHEMAS_ELEM_GLOBAL:
*
* the element is global
*/
#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
/**
* XML_SCHEMAS_ELEM_DEFAULT:
*
* the element has a default value
*/
#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
/**
* XML_SCHEMAS_ELEM_FIXED:
*
* the element has a fixed value
*/
#define XML_SCHEMAS_ELEM_FIXED 1 << 3
#define XML_SCHEMAS_ELEM_FIXED 1 << 3
/**
* XML_SCHEMAS_ELEM_ABSTRACT:
*
* the element is abstract
*/
#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
/**
* XML_SCHEMAS_ELEM_TOPLEVEL:
*
* the element is top level
* obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead
*/
#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
/**
* XML_SCHEMAS_ELEM_REF:
*
* the element is a reference to a type
*/
#define XML_SCHEMAS_ELEM_REF 1 << 6
#define XML_SCHEMAS_ELEM_REF 1 << 6
/**
* XML_SCHEMAS_ELEM_NSDEFAULT:
*
* allow elements in no namespace
* Obsolete, not used anymore.
*/
#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
/**
* XML_SCHEMAS_ELEM_INTERNAL_RESOLVED
*
* this is set when "type", "ref", "substitutionGroup"
* references have been resolved.
*/
#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8
#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8
/**
* XML_SCHEMAS_ELEM_CIRCULAR
*
* a helper flag for the search of circular references.
*/
#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9
#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9
/**
* XML_SCHEMAS_ELEM_BLOCK_ABSENT:
*
* the "block" attribute is absent
*/
#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10
#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10
/**
* XML_SCHEMAS_ELEM_BLOCK_EXTENSION:
*
* disallowed substitutions are absent
*/
#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11
#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11
/**
* XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:
*
* disallowed substitutions: "restriction"
*/
#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12
#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12
/**
* XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:
*
* disallowed substitutions: "substituion"
*/
#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13
#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13
/**
* XML_SCHEMAS_ELEM_FINAL_ABSENT:
*
* substitution group exclusions are absent
*/
#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14
#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14
/**
* XML_SCHEMAS_ELEM_BLOCK_EXTENSION:
*
* substitution group exclusions: "extension"
*/
#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15
#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15
/**
* XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:
*
* substitution group exclusions: "restriction"
*/
#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16
#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16
typedef struct _xmlSchemaElement xmlSchemaElement;
typedef xmlSchemaElement *xmlSchemaElementPtr;
struct _xmlSchemaElement {
xmlSchemaTypeType type; /* The kind of type */
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaType *next;/* the next type if in a sequence ... */
const xmlChar *name;
const xmlChar *id;
......@@ -656,30 +657,30 @@ struct _xmlSchemaElement {
*
* unknown facet handling
*/
#define XML_SCHEMAS_FACET_UNKNOWN 0
#define XML_SCHEMAS_FACET_UNKNOWN 0
/*
* XML_SCHEMAS_FACET_PRESERVE:
*
* preserve the type of the facet
*/
#define XML_SCHEMAS_FACET_PRESERVE 1
#define XML_SCHEMAS_FACET_PRESERVE 1
/*
* XML_SCHEMAS_FACET_REPLACE:
*
* replace the type of the facet
*/
#define XML_SCHEMAS_FACET_REPLACE 2
#define XML_SCHEMAS_FACET_REPLACE 2
/*
* XML_SCHEMAS_FACET_COLLAPSE:
*
* collapse the types of the facet
*/
#define XML_SCHEMAS_FACET_COLLAPSE 3
#define XML_SCHEMAS_FACET_COLLAPSE 3
/**
* A facet definition.
*/
struct _xmlSchemaFacet {
xmlSchemaTypeType type; /* The kind of type */
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
const xmlChar *value;
const xmlChar *id;
......@@ -697,7 +698,7 @@ struct _xmlSchemaFacet {
typedef struct _xmlSchemaNotation xmlSchemaNotation;
typedef xmlSchemaNotation *xmlSchemaNotationPtr;
struct _xmlSchemaNotation {
xmlSchemaTypeType type; /* The kind of type */
xmlSchemaTypeType type; /* The kind of type */
const xmlChar *name;
xmlSchemaAnnotPtr annot;
const xmlChar *identifier;
......@@ -708,62 +709,62 @@ struct _xmlSchemaNotation {
*
* the schema requires qualified elements
*/
#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
/**
* XML_SCHEMAS_QUALIF_ATTR:
*
* the schema requires qualified attributes
*/
#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
/**
* XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:
*
* the schema has "extension" in the set of finalDefault.
*/
#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2
#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2
/**
* XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:
*
* the schema has "restriction" in the set of finalDefault.
*/
#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3
#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3
/**
* XML_SCHEMAS_FINAL_DEFAULT_LIST:
*
* the cshema has "list" in the set of finalDefault.
*/
#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4
#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4
/**
* XML_SCHEMAS_FINAL_DEFAULT_UNION:
*
* the schema has "union" in the set of finalDefault.
*/
#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5
#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5
/**
* XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:
*
* the schema has "extension" in the set of blockDefault.
*/
#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6
#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6
/**
* XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:
*
* the schema has "restriction" in the set of blockDefault.
*/
#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7
#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7
/**
* XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:
*
* the schema has "substitution" in the set of blockDefault.
*/
#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8
#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8
/**
* XML_SCHEMAS_INCLUDING_CONVERT_NS:
*
* the schema is currently including an other schema with
* no target namespace.
*/
#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9
#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9
/**
* _xmlSchema:
*
......@@ -786,15 +787,15 @@ struct _xmlSchema {
xmlHashTablePtr schemasImports;
void *_private; /* unused by the library for users or bindings */
void *_private; /* unused by the library for users or bindings */
xmlHashTablePtr groupDecl;
xmlDictPtr dict;
void *includes; /* the includes, this is opaque for now */
int preserve; /* whether to free the document */
int preserve; /* whether to free the document */
};
XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
#ifdef __cplusplus
}
......@@ -802,4 +803,3 @@ XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
#endif /* LIBXML_SCHEMAS_ENABLED */
#endif /* __XML_SCHEMA_INTERNALS_H__ */
......@@ -43,7 +43,7 @@ XMLPUBFUN int XMLCALL
xmlSchemaValidateFacet (xmlSchemaTypePtr base,
xmlSchemaFacetPtr facet,
const xmlChar *value,
xmlSchemaValPtr val);
xmlSchemaValPtr val);
XMLPUBFUN void XMLCALL
xmlSchemaFreeValue (xmlSchemaValPtr val);
XMLPUBFUN xmlSchemaFacetPtr XMLCALL
......
./test/schemas/bug152470_1.xml validates
./test/schemas/deter0_0.xsd:5: element element: Schemas parser error : Element decl. 'book': The content model is not determinist.
./test/schemas/deter0_0.xsd:6: element complexType: Schemas parser error : CT local: The content model is not determinist.
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': Global declaration is absent.
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': Global declaration is absent.
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': No matching global declaration available.
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': Global declaration is absent.
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': Global declaration is absent.
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element 'foo': No matching global declaration available.
<?xml version="1.0"?>
<roap:deviceHello
xmlns:roap="urn:oma:bac:dldrm:roap-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deviceID>
<keyIdentifier
><hash>vXENc+Um/9/NvmYKiHDLaErK0gk=</hash></keyIdentifier>
</deviceID>
</roap:deviceHello>
\ No newline at end of file
<?xml version="1.0"?>
<schema
targetNamespace="urn:oma:bac:dldrm:roap-1.0"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:roap="urn:oma:bac:dldrm:roap-1.0"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<!-- Basic Types -->
<complexType name="Request" abstract="true"/>
<!-- Basic types to identify entities -->
<complexType name="Identifier">
<choice>
<element name="keyIdentifier" type="roap:KeyIdentifier"/>
</choice>
</complexType>
<complexType name="KeyIdentifier" abstract="true"/>
<complexType name="X509SPKIHash">
<complexContent>
<extension base="roap:KeyIdentifier">
<sequence>
<element name="hash" type="base64Binary"/>
</sequence>
<attribute name="algorithm" type="anyURI"
default="http://www.w3.org/2000/09/xmldsig#sha1"/>
</extension>
</complexContent>
</complexType>
<element name="deviceHello" type="roap:DeviceHello"/>
<complexType name="DeviceHello">
<complexContent>
<extension base="roap:Request">
<sequence>
<element name="deviceID" type="roap:Identifier"
maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
This diff is collapsed.
This diff is collapsed.
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