You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by "George T. Joseph" <gt...@peakin.com> on 2000/01/30 05:55:15 UTC
Xerces-J bug in XSchemaValidator.java
I'm test driving the 12/17 Schema WD support and think I found a bug...
Specifying an attributeGroup reference in a type declaration causes an error if
at least one attribute isn't defined before it. The error is: "Datatype
qualifiers can only be used if you specify a type attribute." Although the
syntax changed, this should still be legal.
Using the sample DOMCount or SAXCount, the following short test files will
reproduce the problem. A stack trace only shows up if you modify DOMCount or
SAXCount to print it (which I did and the trace is appended below).
george
-------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 19991216//EN"
"http://www.w3.org/TR/1999/WD-xmlschema-1-19991217/structures.dtd">
<schema>
<attributeGroup name='group1'>
<attribute name='name1' type='string'/>
</attributeGroup>
<element name='element2'>
<type content='empty'>
<attributeGroup ref='group1'/> //ERROR ERROR ERROR
</type>
</element>
<element name='element1'>
<type content='elementOnly'>
<element ref='element2'/>
<attribute name='xmlns' type='string'/>
<attributeGroup ref='group1'/> //OK OK OK
</type>
</element>
</schema>
<?xml version="1.0" encoding="us-ascii"?>
<element1 xmlns='test.xsd'>
<element2 name1='q'/>
</element1>
[Error] test.xml:2:27: Datatype qualifiers can only be used if you specify a
type attribute.
Datatype qualifiers can only be used if you specify a type attribute.
at org.apache.xerces.framework.XMLParser.reportErrorXMLParser.java:1264)
at org.apache.xerces.validators.schema.XSchemaValidator.reportSchemaError
XSchemaValidator.java:2907)
at
org.apache.xerces.validators.schema.XSchemaValidator.traverseTypeDecl(XSchemaVal
idator.java:1932)
at
org.apache.xerces.validators.schema.XSchemaValidator.traverseElementDecl(XSchema
Validator.java:2208)
at
org.apache.xerces.validators.schema.XSchemaValidator.traverseSchema(XSchemaValid
ator.java:1731)
at
org.apache.xerces.validators.schema.XSchemaValidator.loadSchema(XSchemaValidator
.java:1699)
at org.apache.xerces.framework.XMLParser.scanAttValue(XMLParser.java:1952)
at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.ja
va:1800)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDoc
umentScanner.java:991)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java
:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1145)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1184)
at sax.SAXCount.print(SAXCount.java:135)
at sax.SAXCount.main(SAXCount.java:332)
test.xml: 1100 ms (1 elems, 2 attrs, 0 spaces, 0 chars)
RE: Xerces-J bug in XSchemaValidator.java (I figured it out and patched it.)
Posted by "George T. Joseph" <gt...@peakin.com>.
I figured it out... A very small patch needs to be applied to
XSchemaValidator.java.
*** XSchemaValidator.java Fri Jan 28 19:27:00 2000
--- XSchemaValidator.new Sun Jan 30 13:08:48 2000
***************
*** 1922,1928 ****
else // buildAll
reportSchemaError(SchemaMessageProvider.OrderIsAll,
new Object [] { "group" } );
! } else if (childName.equals(ELT_ATTRIBUTEDECL)) {
break; // attr processing is done be low
} else if (childName.equals(ELT_ANY)) {
contentSpecType = fStringPool.addSymbol("ANY");
--- 1922,1929 ----
else // buildAll
reportSchemaError(SchemaMessageProvider.OrderIsAll,
new Object [] { "group" } );
! } else if (childName.equals(ELT_ATTRIBUTEDECL) ||
! childName.equals(ELT_ATTRGROUPDECL)) {
break; // attr processing is done be low
} else if (childName.equals(ELT_ANY)) {
contentSpecType = fStringPool.addSymbol("ANY");
-----Original Message-----
From: George T. Joseph [mailto:gtj@peakin.com]
Sent: Saturday, January 29, 2000 11:55 PM
To: xerces-dev
Subject: Xerces-J bug in XSchemaValidator.java
I'm test driving the 12/17 Schema WD support and think I found a bug...
Specifying an attributeGroup reference in a type declaration causes an error if
at least one attribute isn't defined before it. The error is: "Datatype
qualifiers can only be used if you specify a type attribute." Although the
syntax changed, this should still be legal.
Using the sample DOMCount or SAXCount, the following short test files will
reproduce the problem. A stack trace only shows up if you modify DOMCount or
SAXCount to print it (which I did and the trace is appended below).
george
-------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 19991216//EN"
"http://www.w3.org/TR/1999/WD-xmlschema-1-19991217/structures.dtd">
<schema>
<attributeGroup name='group1'>
<attribute name='name1' type='string'/>
</attributeGroup>
<element name='element2'>
<type content='empty'>
<attributeGroup ref='group1'/> //ERROR ERROR ERROR
</type>
</element>
<element name='element1'>
<type content='elementOnly'>
<element ref='element2'/>
<attribute name='xmlns' type='string'/>
<attributeGroup ref='group1'/> //OK OK OK
</type>
</element>
</schema>
<?xml version="1.0" encoding="us-ascii"?>
<element1 xmlns='test.xsd'>
<element2 name1='q'/>
</element1>
[Error] test.xml:2:27: Datatype qualifiers can only be used if you specify a
type attribute.
Datatype qualifiers can only be used if you specify a type attribute.
at org.apache.xerces.framework.XMLParser.reportErrorXMLParser.java:1264)
at org.apache.xerces.validators.schema.XSchemaValidator.reportSchemaError
XSchemaValidator.java:2907)
at
org.apache.xerces.validators.schema.XSchemaValidator.traverseTypeDecl(XSchemaVal
idator.java:1932)
at
org.apache.xerces.validators.schema.XSchemaValidator.traverseElementDecl(XSchema
Validator.java:2208)
at
org.apache.xerces.validators.schema.XSchemaValidator.traverseSchema(XSchemaValid
ator.java:1731)
at
org.apache.xerces.validators.schema.XSchemaValidator.loadSchema(XSchemaValidator
.java:1699)
at org.apache.xerces.framework.XMLParser.scanAttValue(XMLParser.java:1952)
at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.ja
va:1800)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDoc
umentScanner.java:991)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java
:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1145)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1184)
at sax.SAXCount.print(SAXCount.java:135)
at sax.SAXCount.main(SAXCount.java:332)
test.xml: 1100 ms (1 elems, 2 attrs, 0 spaces, 0 chars)