1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

lot of bug fixes, cleanup, starting to add proper namespace support too.

* xmlschemas.c xmlschemastypes.c include/libxml/xmlerror.h
  include/libxml/schemasInternals.h: lot of bug fixes, cleanup,
  starting to add proper namespace support too.
* test/schemas/* result/schemas/*: added a number of tests
  fixed the result from some regression tests too.
Daniel
This commit is contained in:
Daniel Veillard 2003-11-22 20:37:51 +00:00
parent 2b7142a1b3
commit be9c6320d4
65 changed files with 1029 additions and 316 deletions

View File

@ -1,3 +1,11 @@
Sat Nov 22 21:35:42 CET 2003 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c xmlschemastypes.c include/libxml/xmlerror.h
include/libxml/schemasInternals.h: lot of bug fixes, cleanup,
starting to add proper namespace support too.
* test/schemas/* result/schemas/*: added a number of tests
fixed the result from some regression tests too.
Fri Nov 21 20:50:59 MST 2003 John Fleck <jfleck@inkstain.net>
* doc/xml.html, docs.html: remove reference to gtk-doc now that

View File

@ -18,6 +18,7 @@
#include <libxml/xmlregexp.h>
#include <libxml/hash.h>
#include <libxml/dict.h>
#ifdef __cplusplus
extern "C" {
@ -100,24 +101,33 @@ struct _xmlSchemaAnnot {
#define XML_SCHEMAS_ANYATTR_LAX 2
#define XML_SCHEMAS_ANYATTR_STRICT 3
/**
* XML_SCHEMAS_ATTR_NSDEFAULT:
*
* allow elements in no namespace
*/
#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
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 ... */
xmlChar *name;
xmlChar *id;
xmlChar *ref;
xmlChar *refNs;
xmlChar *typeName;
xmlChar *typeNs;
const xmlChar *name;
const xmlChar *id;
const xmlChar *ref;
const xmlChar *refNs;
const xmlChar *typeName;
const xmlChar *typeNs;
xmlSchemaAnnotPtr annot;
xmlSchemaTypePtr base;
int occurs;
xmlChar *defValue;
const xmlChar *defValue;
xmlSchemaTypePtr subtypes;
xmlNodePtr node;
const xmlChar *targetNamespace;
int flags;
};
/**
@ -131,10 +141,10 @@ typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
struct _xmlSchemaAttributeGroup {
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
xmlChar *name;
xmlChar *id;
xmlChar *ref;
xmlChar *refNs;
const xmlChar *name;
const xmlChar *id;
const xmlChar *ref;
const xmlChar *refNs;
xmlSchemaAnnotPtr annot;
xmlSchemaAttributePtr attributes;
@ -157,10 +167,10 @@ struct _xmlSchemaAttributeGroup {
struct _xmlSchemaType {
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaType *next;/* the next type if in a sequence ... */
xmlChar *name;
xmlChar *id;
xmlChar *ref;
xmlChar *refNs;
const xmlChar *name;
const xmlChar *id;
const xmlChar *ref;
const xmlChar *refNs;
xmlSchemaAnnotPtr annot;
xmlSchemaTypePtr subtypes;
xmlSchemaAttributePtr attributes;
@ -170,8 +180,8 @@ struct _xmlSchemaType {
int flags;
xmlSchemaContentType contentType;
xmlChar *base;
xmlChar *baseNs;
const xmlChar *base;
const xmlChar *baseNs;
xmlSchemaTypePtr baseType;
xmlSchemaFacetPtr facets;
};
@ -225,16 +235,22 @@ struct _xmlSchemaType {
* the element is a reference to a type
*/
#define XML_SCHEMAS_ELEM_REF 1 << 6
/**
* XML_SCHEMAS_ELEM_NSDEFAULT:
*
* allow elements in no namespace
*/
#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
typedef struct _xmlSchemaElement xmlSchemaElement;
typedef xmlSchemaElement *xmlSchemaElementPtr;
struct _xmlSchemaElement {
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaType *next;/* the next type if in a sequence ... */
xmlChar *name;
xmlChar *id;
xmlChar *ref;
xmlChar *refNs;
const xmlChar *name;
const xmlChar *id;
const xmlChar *ref;
const xmlChar *refNs;
xmlSchemaAnnotPtr annot;
xmlSchemaTypePtr subtypes;
xmlSchemaAttributePtr attributes;
@ -243,13 +259,13 @@ struct _xmlSchemaElement {
int maxOccurs;
int flags;
xmlChar *targetNamespace;
xmlChar *namedType;
xmlChar *namedTypeNs;
xmlChar *substGroup;
xmlChar *substGroupNs;
xmlChar *scope;
xmlChar *value;
const xmlChar *targetNamespace;
const xmlChar *namedType;
const xmlChar *namedTypeNs;
const xmlChar *substGroup;
const xmlChar *substGroupNs;
const xmlChar *scope;
const xmlChar *value;
struct _xmlSchemaElement *refDecl;
xmlRegexpPtr contModel;
xmlSchemaContentType contentType;
@ -286,8 +302,8 @@ struct _xmlSchemaElement {
struct _xmlSchemaFacet {
xmlSchemaTypeType type; /* The kind of type */
struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
xmlChar *value;
xmlChar *id;
const xmlChar *value;
const xmlChar *id;
xmlSchemaAnnotPtr annot;
xmlNodePtr node;
int fixed;
@ -303,9 +319,9 @@ typedef struct _xmlSchemaNotation xmlSchemaNotation;
typedef xmlSchemaNotation *xmlSchemaNotationPtr;
struct _xmlSchemaNotation {
xmlSchemaTypeType type; /* The kind of type */
xmlChar *name;
const xmlChar *name;
xmlSchemaAnnotPtr annot;
xmlChar *identifier;
const xmlChar *identifier;
};
/**
@ -326,10 +342,10 @@ struct _xmlSchemaNotation {
* A Schemas definition
*/
struct _xmlSchema {
xmlChar *name; /* schema name */
xmlChar *targetNamespace; /* the target namespace */
xmlChar *version;
xmlChar *id;
const xmlChar *name; /* schema name */
const xmlChar *targetNamespace; /* the target namespace */
const xmlChar *version;
const xmlChar *id;
xmlDocPtr doc;
xmlSchemaAnnotPtr annot;
int flags;
@ -344,6 +360,7 @@ struct _xmlSchema {
void *_private; /* unused by the library for users or bindings */
xmlHashTablePtr groupDecl;
xmlDictPtr dict;
};
XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);

View File

@ -535,6 +535,8 @@ typedef enum {
XML_SCHEMAP_REDEFINED_ATTR, /* 1763 */
XML_SCHEMAP_REDEFINED_NOTATION, /* 1764 */
XML_SCHEMAP_FAILED_PARSE, /* 1765 */
XML_SCHEMAP_UNKNOWN_PREFIX, /* 1766 */
XML_SCHEMAP_DEF_AND_PREFIX, /* 1767 */
XML_SCHEMAV_NOROOT = 1800,
XML_SCHEMAV_UNDECLAREDELEM, /* 1801 */
XML_SCHEMAV_NOTTOPLEVEL, /* 1802 */

View File

View File

@ -0,0 +1 @@
./test/schemas/deter0_0.xsd:5: element element: Schemas parser error : Content model of book is not determinist:

View File

@ -0,0 +1 @@
./test/schemas/extension1_0.xml validates

View File

View File

@ -0,0 +1 @@
./test/schemas/extension1_1.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/extension1_1.xml:1: element title: Schemas validity error : Attribute langue on title is unknown

View File

@ -0,0 +1 @@
./test/schemas/extension1_2.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/extension1_2.xml:1: element title: Schemas validity error : Element title: child salut should not be present

View File

@ -0,0 +1 @@
./test/schemas/group0_0.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/group0_0.xml:1: element author: Schemas validity error : Element author content check failed

1
result/schemas/ns0_0_0 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_0.xml validates

View File

1
result/schemas/ns0_0_1 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_1.xml validates

View File

1
result/schemas/ns0_0_2 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_2.xml fails to validate

View File

@ -0,0 +1,2 @@
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element foo not declared
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element foo not declared

1
result/schemas/ns0_0_3 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_3.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/ns0_3.xml:1: element foo: Schemas validity error : Attribute id on foo is unknown

1
result/schemas/ns0_0_4 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_4.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/ns0_4.xml:2: element foo: Schemas validity error : Attribute id on foo is unknown

1
result/schemas/ns0_1_0 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_0.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/ns0_0.xml:1: element foo: Schemas validity error : Attribute id on foo is unknown

1
result/schemas/ns0_1_1 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_1.xml fails to validate

View File

@ -0,0 +1 @@
./test/schemas/ns0_1.xml:1: element foo: Schemas validity error : Attribute id on foo is unknown

1
result/schemas/ns0_1_2 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_2.xml fails to validate

View File

@ -0,0 +1,2 @@
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element foo not declared
./test/schemas/ns0_2.xml:1: element foo: Schemas validity error : Element foo not declared

1
result/schemas/ns0_1_3 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_3.xml validates

View File

1
result/schemas/ns0_1_4 Normal file
View File

@ -0,0 +1 @@
./test/schemas/ns0_4.xml validates

View File

View File

@ -1 +1 @@
./test/schemas/po1_0.xml fails to validate
./test/schemas/po1_0.xml validates

View File

@ -1,5 +0,0 @@
Schemas: element items type Items not found
Schemas: element anonelem9 ref to comment not found
Schemas: element anonelem2 ref to comment not found
Schemas: attribute partNum type SKU not found
Element purchaseOrder content check failed

View File

@ -0,0 +1 @@
./test/schemas/vdv-first0_0.xml validates

View File

View File

@ -0,0 +1 @@
./test/schemas/vdv-first1_0.xml validates

View File

View File

@ -0,0 +1 @@
./test/schemas/vdv-first2_0.xml validates

View File

View File

@ -0,0 +1 @@
./test/schemas/vdv-first3_0.xml validates

View File

16
test/schemas/all.xsd Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:all>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
<xsd:element name="items" type="Items"/>
</xsd:all>
<xsd:sequence>
<xsd:element ref="comment" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
</xsd:schema>

View File

@ -0,0 +1 @@
<title lang="fr">salut</title>

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<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:element name="title">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="string255">
<xs:attribute name="lang" type="xs:language"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1 @@
<title langue="fr">salut</title>

View File

@ -0,0 +1 @@
<title lang="fr"><salut/></title>

2
test/schemas/ns0_0.xml Normal file
View File

@ -0,0 +1,2 @@
<foo xmlns="http://example.com/xsd/ns" id="abc"/>

16
test/schemas/ns0_0.xsd Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/xsd/ns"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:element name="foo">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="id" type="xsd:ID"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>

2
test/schemas/ns0_1.xml Normal file
View File

@ -0,0 +1,2 @@
<n:foo xmlns:n="http://example.com/xsd/ns" id="abc"/>

16
test/schemas/ns0_1.xsd Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/xsd/ns"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xsd:element name="foo">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="id" type="xsd:ID"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>

2
test/schemas/ns0_2.xml Normal file
View File

@ -0,0 +1,2 @@
<foo id="abc"/>

2
test/schemas/ns0_3.xml Normal file
View File

@ -0,0 +1,2 @@
<n:foo xmlns:n="http://example.com/xsd/ns" n:id="abc"/>

3
test/schemas/ns0_4.xml Normal file
View File

@ -0,0 +1,3 @@
<l:foo xmlns:l="http://example.com/xsd/ns"
xmlns:b="http://example.com/xsd/ns" b:id="abc"/>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first.xml,v 1.2 2001/11/01 22:03:06 vdv 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>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="name" type="xs:string"/>
<xs:element name="qualification" type="xs:string"/>
<xs:element name="born" type="xs:date"/>
<xs:element name="dead" type="xs:date"/>
<xs:element name="isbn" type="xs:integer"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="available" type="xs:boolean"/>
<xs:attribute name="lang" type="xs:language"/>
<xs:element name="title">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<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="author">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="born"/>
<xs:element ref="dead" minOccurs="0"/>
</xs:sequence>
<xs:attribute ref="id"/>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<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="id"/>
<xs:attribute ref="available"/>
</xs:complexType>
</xs:element>
<xs:element name="character">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="born"/>
<xs:element ref="qualification"/>
</xs:sequence>
<xs:attribute ref="id"/>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first.xml,v 1.2 2001/11/01 22:03:06 vdv 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>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="isbn" type="xs:integer"/>
<xs:element name="title">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="lang" type="xs:language"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="author" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="born" type="xs:date"/>
<xs:element name="dead" type="xs:date"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>
<xs:element name="character" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="born" type="xs:date"/>
<xs:element name="qualification" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="available" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first.xml,v 1.2 2001/11/01 22:03:06 vdv 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>

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first-user-dt.xsd,v 1.1 2001/11/01 12:27:47 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: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:element name="name" type="string32"/>
<xs:element name="qualification" type="string255"/>
<xs:element name="born" type="xs:date"/>
<xs:element name="dead" type="xs: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: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="author">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="born"/>
<xs:element ref="dead" minOccurs="0"/>
</xs:sequence>
<xs:attribute ref="id"/>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<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="id"/>
<xs:attribute ref="available"/>
</xs:complexType>
</xs:element>
<xs:element name="character">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="born"/>
<xs:element ref="qualification"/>
</xs:sequence>
<xs:attribute ref="id"/>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first.xml,v 1.2 2001/11/01 22:03:06 vdv 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>

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first-token.xsd,v 1.2 2001/11/01 12:27:47 vdv Exp $ -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="name" type="xs:token"/>
<xs:element name="qualification" type="xs:token"/>
<xs:element name="born" type="xs:date"/>
<xs:element name="dead" type="xs:date"/>
<xs:element name="isbn" type="xs:unsignedLong"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute name="available" type="xs:boolean"/>
<xs:attribute name="lang" type="xs:language"/>
<xs:element name="title">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:token">
<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="author">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="born"/>
<xs:element ref="dead" minOccurs="0"/>
</xs:sequence>
<xs:attribute ref="id"/>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<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="id"/>
<xs:attribute ref="available"/>
</xs:complexType>
</xs:element>
<xs:element name="character">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="born"/>
<xs:element ref="qualification"/>
</xs:sequence>
<xs:attribute ref="id"/>
</xs:complexType>
</xs:element>
</xs:schema>

File diff suppressed because it is too large Load Diff

View File

@ -261,7 +261,7 @@ xmlSchemaInitBasicType(const char *name, xmlSchemaValType type) {
return(NULL);
}
memset(ret, 0, sizeof(xmlSchemaType));
ret->name = xmlStrdup((const xmlChar *)name);
ret->name = (const xmlChar *)name;
ret->type = XML_SCHEMA_TYPE_BASIC;
ret->flags = type;
ret->contentType = XML_SCHEMA_CONTENT_BASIC;