You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Eric Ye <er...@locus.apache.org> on 2000/09/20 03:16:52 UTC
Re: Help with schema validation
I have to admit the error message itself is not so helpful.
The problem is in the definition of complex type "GroupType", the attribute decl should come after all the element decls, according to the complexType concrete syntax that can be found in Schema Structures Section 4.3.3.
The error should have detected if the parser validate the schema itself when compile it, for now the validation is turned off for various reasons. This means you will see more meaningful error messages in the future.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: Tarek Hammoud
To: xerces-j-dev@xml.apache.org
Sent: Tuesday, September 19, 2000 7:34 PM
Subject: Help with schema validation
Hello,
I keep getting this error from the parser. I am attaching the schema and the instance document. Please help and shed some light on this. Thanks.
Tarek Hammoud
org.xml.sax.SAXParseException: Schema error: complexType 'GroupType' with a ele
mentOnly or mixed content need to have at least one particle child.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1016
)
at org.apache.xerces.validators.schema.TraverseSchema.reportSchemaError(
TraverseSchema.java:4355)
at org.apache.xerces.validators.schema.TraverseSchema.reportGenericSchem
aError(TraverseSchema.java:4342)
at org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
eDecl(TraverseSchema.java:1877)
at org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
l(TraverseSchema.java:3038)
at org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
eDecl(TraverseSchema.java:1774)
at org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
l(TraverseSchema.java:2930)
<xsd:schema targetNamespace='http://www.rochalin.com/Sample' elementFormDefault="qualified"
xmlns:xsd='http://www.w3.org/1999/XMLSchema'
xmlns:sample='http://www.rochalin.com/Sample'>
<xsd:element name="treeMap">
<xsd:complexType>
<xsd:element name="group" type="sample:GroupType" minOccurs='1' maxOccurs='unbounded'/>
</xsd:complexType>
</xsd:element>
<!-- Each group can have 1 or more children and 1 or more groups -->
<xsd:complexType name="GroupType">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:element name="child" type="sample:TreeMapElementType" minOccurs='0' maxOccurs='unbounded'/>
<xsd:element name="childGroup" type="sample:GroupType" minOccurs='0' maxOccurs='unbounded'/>
</xsd:complexType>
<!-- The child node -->
<xsd:complexType name="TreeMapElementType" content="empty">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="weight" type="xsd:double" use="required"/>
<xsd:attribute name="percentChange" type="xsd:double" use="required"/>
</xsd:complexType>
</xsd:schema>
Document
---------------
<?xml version="1.0"?>
<sample:treeMap xmlns:sample='http://www.rochalin.com/Sample'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xsi:schemaLocation='http://www.rochalin.com/Sample
test.xsd'>
<sample:group name="Internet"/>
</sample:treeMap>
Re: Help with schema validation
Posted by Tarek Hammoud <ma...@c158163-a.mntp1.il.home.com>.
Eric,
I moved the lines around and it worked like a charm. Thanks a lot.
Tarek
----- Original Message -----
From: Eric Ye
To: xerces-j-dev@xml.apache.org
Sent: Tuesday, September 19, 2000 6:16 PM
Subject: Re: Help with schema validation
I have to admit the error message itself is not so helpful.
The problem is in the definition of complex type "GroupType", the attribute decl should come after all the element decls, according to the complexType concrete syntax that can be found in Schema Structures Section 4.3.3.
The error should have detected if the parser validate the schema itself when compile it, for now the validation is turned off for various reasons. This means you will see more meaningful error messages in the future.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: Tarek Hammoud
To: xerces-j-dev@xml.apache.org
Sent: Tuesday, September 19, 2000 7:34 PM
Subject: Help with schema validation
Hello,
I keep getting this error from the parser. I am attaching the schema and the instance document. Please help and shed some light on this. Thanks.
Tarek Hammoud
org.xml.sax.SAXParseException: Schema error: complexType 'GroupType' with a ele
mentOnly or mixed content need to have at least one particle child.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1016
)
at org.apache.xerces.validators.schema.TraverseSchema.reportSchemaError(
TraverseSchema.java:4355)
at org.apache.xerces.validators.schema.TraverseSchema.reportGenericSchem
aError(TraverseSchema.java:4342)
at org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
eDecl(TraverseSchema.java:1877)
at org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
l(TraverseSchema.java:3038)
at org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
eDecl(TraverseSchema.java:1774)
at org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
l(TraverseSchema.java:2930)
<xsd:schema targetNamespace='http://www.rochalin.com/Sample' elementFormDefault="qualified"
xmlns:xsd='http://www.w3.org/1999/XMLSchema'
xmlns:sample='http://www.rochalin.com/Sample'>
<xsd:element name="treeMap">
<xsd:complexType>
<xsd:element name="group" type="sample:GroupType" minOccurs='1' maxOccurs='unbounded'/>
</xsd:complexType>
</xsd:element>
<!-- Each group can have 1 or more children and 1 or more groups -->
<xsd:complexType name="GroupType">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:element name="child" type="sample:TreeMapElementType" minOccurs='0' maxOccurs='unbounded'/>
<xsd:element name="childGroup" type="sample:GroupType" minOccurs='0' maxOccurs='unbounded'/>
</xsd:complexType>
<!-- The child node -->
<xsd:complexType name="TreeMapElementType" content="empty">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="weight" type="xsd:double" use="required"/>
<xsd:attribute name="percentChange" type="xsd:double" use="required"/>
</xsd:complexType>
</xsd:schema>
Document
---------------
<?xml version="1.0"?>
<sample:treeMap xmlns:sample='http://www.rochalin.com/Sample'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xsi:schemaLocation='http://www.rochalin.com/Sample
test.xsd'>
<sample:group name="Internet"/>
</sample:treeMap>
Re: Help with schema validation
Posted by Eric Ye <er...@locus.apache.org>.
There are some documentation regarding schema support in the Readme.html, which was distributed with binary package.
Currently there is no docs that describes the design of the Schema support in Xerces-J, someting is on the way though.
Before the parser can validate the instance document with a Schema, it will need to read in the Schema file(actually also a XML file) and compile it to some internal grammar structure, in the current implementation, the schema compilation was done by, first parsing the schema to construct a DOM tree , and then traversing the tree and extracting all the needed info for validating later on. At the stage of parsing the schema to a DOM tree, you have the option to turn on the validation or not. To validate a schema against a higher meta-level grammar, which could be a Schema for schema or a DTD for Schema, or even some forms of internal built-in grammar, is quite similar to using a schema to validate a instance XML file, both for checking the validityof a XML file, if you turn it on, the benefit is the parser could find validity errors in addition to well-formness errors in a schema.
Hope this helps.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: Werner Guttmann
To: xerces-j-dev@xml.apache.org
Sent: Wednesday, September 20, 2000 12:46 AM
Subject: Re: Help with schema validation
Eric,
are there any documents which would describe features as pointed out below, e.g. support for schema compilation, etc. Or even better, could you maybe explain how schema validation will work, how it will be turned on and what benefits we will see ?
Regards
Werner Guttmann
Eric Ye wrote:
I have to admit the error message itself is not so helpful. The problem is in the definition of complex type "GroupType", the attribute decl should come after all the element decls, according to the complexType concrete syntax that can be found in Schema Structures Section 4.3.3. The error should have detected if the parser validate the schema itself when compile it, for now the validation is turned off for various reasons. This means you will see more meaningful error messages in the future._____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: Tarek Hammoud
To: xerces-j-dev@xml.apache.org
Sent: Tuesday, September 19, 2000 7:34 PM
Subject: Help with schema validation
Hello, I keep getting this error from the parser. I am attaching the schema and the instance document. Please help and shed some light on this. Thanks. Tarek Hammoud org.xml.sax.SAXParseException: Schema error: complexType 'GroupType' with a ele
mentOnly or mixed content need to have at least one particle child.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1016
)
at org.apache.xerces.validators.schema.TraverseSchema.reportSchemaError(
TraverseSchema.java:4355)
at org.apache.xerces.validators.schema.TraverseSchema.reportGenericSchem
aError(TraverseSchema.java:4342)
at org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
eDecl(TraverseSchema.java:1877)
at org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
l(TraverseSchema.java:3038)
at org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
eDecl(TraverseSchema.java:1774)
at org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
l(TraverseSchema.java:2930) <xsd:schema targetNamespace='http://www.rochalin.com/Sample' elementFormDefault="qualified"
xmlns:xsd='http://www.w3.org/1999/XMLSchema'
xmlns:sample='http://www.rochalin.com/Sample'> <xsd:element name="treeMap">
<xsd:complexType>
<xsd:element name="group" type="sample:GroupType" minOccurs='1' maxOccurs='unbounded'/>
</xsd:complexType>
</xsd:element> <!-- Each group can have 1 or more children and 1 or more groups -->
<xsd:complexType name="GroupType">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:element name="child" type="sample:TreeMapElementType" minOccurs='0' maxOccurs='unbounded'/>
<xsd:element name="childGroup" type="sample:GroupType" minOccurs='0' maxOccurs='unbounded'/>
</xsd:complexType> <!-- The child node -->
<xsd:complexType name="TreeMapElementType" content="empty">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="weight" type="xsd:double" use="required"/>
<xsd:attribute name="percentChange" type="xsd:double" use="required"/>
</xsd:complexType> </xsd:schema> Document---------------<?xml version="1.0"?> <sample:treeMap xmlns:sample='http://www.rochalin.com/Sample'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
xsi:schemaLocation='http://www.rochalin.com/Sample
test.xsd'> <sample:group name="Internet"/>
</sample:treeMap>
Re: Help with schema validation
Posted by Werner Guttmann <We...@msdw.com>.
Eric,
are there any documents which would describe features as pointed out
below, e.g. support for schema compilation, etc. Or even better, could
you maybe explain how schema validation will work, how it will be turned
on and what benefits we will see ?
Regards
Werner Guttmann
Eric Ye wrote:
> I have to admit the error message itself is not so helpful. The
> problem is in the definition of complex type "GroupType", the
> attribute decl should come after all the element decls, according to
> the complexType concrete syntax that can be found in Schema Structures
> Section 4.3.3. The error should have detected if the parser validate
> the schema itself when compile it, for now the validation is turned
> off for various reasons. This means you will see more meaningful error
> messages in the future._____
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
> ----- Original Message -----
> From: Tarek Hammoud
> To: xerces-j-dev@xml.apache.org
> Sent: Tuesday, September 19, 2000 7:34 PM
> Subject: Help with schema validation
> Hello, I keep getting this error from the parser. I am
> attaching the schema and the instance document. Please help
> and shed some light on this. Thanks. Tarek
> Hammoud org.xml.sax.SAXParseException: Schema error:
> complexType 'GroupType' with a ele
> mentOnly or mixed content need to have at least one particle
> child.
> at
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1016
>
> )
> at
> org.apache.xerces.validators.schema.TraverseSchema.reportSchemaError(
>
> TraverseSchema.java:4355)
> at
> org.apache.xerces.validators.schema.TraverseSchema.reportGenericSchem
>
> aError(TraverseSchema.java:4342)
> at
> org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
>
> eDecl(TraverseSchema.java:1877)
> at
> org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
>
> l(TraverseSchema.java:3038)
> at
> org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTyp
>
> eDecl(TraverseSchema.java:1774)
> at
> org.apache.xerces.validators.schema.TraverseSchema.traverseElementDec
>
> l(TraverseSchema.java:2930) <xsd:schema
> targetNamespace='http://www.rochalin.com/Sample'
> elementFormDefault="qualified"
> xmlns:xsd='http://www.w3.org/1999/XMLSchema'
>
> xmlns:sample='http://www.rochalin.com/Sample'> <xsd:element
> name="treeMap">
> <xsd:complexType>
> <xsd:element name="group" type="sample:GroupType"
> minOccurs='1' maxOccurs='unbounded'/>
> </xsd:complexType>
> </xsd:element> <!-- Each group can have 1 or more children
> and 1 or more groups -->
> <xsd:complexType name="GroupType">
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:element name="child"
> type="sample:TreeMapElementType" minOccurs='0'
> maxOccurs='unbounded'/>
> <xsd:element name="childGroup" type="sample:GroupType"
> minOccurs='0' maxOccurs='unbounded'/>
> </xsd:complexType> <!-- The child node -->
> <xsd:complexType name="TreeMapElementType" content="empty">
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="weight" type="xsd:double"
> use="required"/>
> <xsd:attribute name="percentChange" type="xsd:double"
> use="required"/>
>
> /xsd:complexType> </xsd:schema> Document---------------<?xml
> version="1.0"?> <sample:treeMap
> xmlns:sample='http://www.rochalin.com/Sample'
> xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
> xsi:schemaLocation='http://www.rochalin.com/Sample
> test.xsd'> <sample:group
> name="Internet"/>
> </sample:treeMap>
>