Name: inR10064 Date: 02/18/2004
The method
public Schema newSchema(File schema)
of the class javax.xml.validation.SchemaFactory does not detect
violations of the "Schema Component Constraint: Unique Particle Attribution"
defined in section "3.8.6 Constraints on Model Group Schema Components"
of XML Schema 1.0 Structures spec :
^BA content model must be formed such that during ?validation? of an element
information item sequence, the particle contained directly, indirectly or
?implicitly? therein with which to attempt to ?validate? each item in the
sequence in turn can be uniquely determined without examining the content or
attributes of that item, and without any information about the items in the
remainder of the sequence.
See the sample and log below. Test schemas of the affected JCK 15 tests contain
definitions like:
<xsd:choice>
<xsd:sequence>
<xsd:element name="b"/>
<xsd:element name="c"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="b"/>
<xsd:element name="d"/>
</xsd:sequence>
</xsd:choice>
which are processed without errors.
The bug found in the JDK 1.5.0-beta-b38. The bug affects the following
new JCK-15 beta2 tests adopted from W3C XSTC-20020116 testsuite:
api/xml_schema/msxsdtest/ModelGroups/mgS002.html#mgS002
api/xml_schema/msxsdtest/ModelGroups/mgS003.html#mgS003
api/xml_schema/msxsdtest/ModelGroups/mgS004.html#mgS004
api/xml_schema/msxsdtest/ModelGroups/mgS005.html#mgS005
---- mgS005.xsd ----------------------------------------------------------------------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="doc" type="foo"/>
<xsd:complexType name="foo">
<xsd:sequence>
<xsd:choice>
<xsd:sequence>
<xsd:element name="a"/>
<xsd:element name="b"/>
</xsd:sequence>
<xsd:choice>
<xsd:sequence>
<xsd:element name="a"/>
<xsd:element name="b"/>
</xsd:sequence>
<xsd:element name="b"/>
</xsd:choice>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
------ LoadSchema.java --------------------------------------------------------------------
package test;
import java.io.File;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.validation.SchemaFactory;
public class LoadSchema {
protected static class ErrorHandler extends DefaultHandler {
public int errorCounter = 0;
public void error(SAXParseException e) throws SAXException {
System.out.println(e);
errorCounter++;
}
public void fatalError(SAXParseException e) throws SAXException {
System.out.println(e);
errorCounter++;
}
}
public static void main(String [] args) {
SchemaFactory schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
ErrorHandler errorHandler = new ErrorHandler();
schemaFactory.setErrorHandler(errorHandler);
try {
schemaFactory.newSchema(new File(args[0]));
} catch (SAXException e) {
exit(1, "Fatal Error: " + e);
}
if (errorHandler.errorCounter != 0) {
exit(1, "Errors reported: " + errorHandler.errorCounter);
} else {
exit(0, "No error reported.");
}
}
public static void exit(int errCode, String msg) {
System.out.println(msg);
System.exit(errCode);
}
}
--------------------------------------------------------------------------
% java -showversion -cp . test.LoadSchema mgS005.xsd
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b38)
Java HotSpot(TM) Server VM (build 1.5.0-beta2-b38, mixed mode)
No error reported.
--------------------------------------------------------------------------
======================================================================
The method
public Schema newSchema(File schema)
of the class javax.xml.validation.SchemaFactory does not detect
violations of the "Schema Component Constraint: Unique Particle Attribution"
defined in section "3.8.6 Constraints on Model Group Schema Components"
of XML Schema 1.0 Structures spec :
^BA content model must be formed such that during ?validation? of an element
information item sequence, the particle contained directly, indirectly or
?implicitly? therein with which to attempt to ?validate? each item in the
sequence in turn can be uniquely determined without examining the content or
attributes of that item, and without any information about the items in the
remainder of the sequence.
See the sample and log below. Test schemas of the affected JCK 15 tests contain
definitions like:
<xsd:choice>
<xsd:sequence>
<xsd:element name="b"/>
<xsd:element name="c"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="b"/>
<xsd:element name="d"/>
</xsd:sequence>
</xsd:choice>
which are processed without errors.
The bug found in the JDK 1.5.0-beta-b38. The bug affects the following
new JCK-15 beta2 tests adopted from W3C XSTC-20020116 testsuite:
api/xml_schema/msxsdtest/ModelGroups/mgS002.html#mgS002
api/xml_schema/msxsdtest/ModelGroups/mgS003.html#mgS003
api/xml_schema/msxsdtest/ModelGroups/mgS004.html#mgS004
api/xml_schema/msxsdtest/ModelGroups/mgS005.html#mgS005
---- mgS005.xsd ----------------------------------------------------------------------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="doc" type="foo"/>
<xsd:complexType name="foo">
<xsd:sequence>
<xsd:choice>
<xsd:sequence>
<xsd:element name="a"/>
<xsd:element name="b"/>
</xsd:sequence>
<xsd:choice>
<xsd:sequence>
<xsd:element name="a"/>
<xsd:element name="b"/>
</xsd:sequence>
<xsd:element name="b"/>
</xsd:choice>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
------ LoadSchema.java --------------------------------------------------------------------
package test;
import java.io.File;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.validation.SchemaFactory;
public class LoadSchema {
protected static class ErrorHandler extends DefaultHandler {
public int errorCounter = 0;
public void error(SAXParseException e) throws SAXException {
System.out.println(e);
errorCounter++;
}
public void fatalError(SAXParseException e) throws SAXException {
System.out.println(e);
errorCounter++;
}
}
public static void main(String [] args) {
SchemaFactory schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
ErrorHandler errorHandler = new ErrorHandler();
schemaFactory.setErrorHandler(errorHandler);
try {
schemaFactory.newSchema(new File(args[0]));
} catch (SAXException e) {
exit(1, "Fatal Error: " + e);
}
if (errorHandler.errorCounter != 0) {
exit(1, "Errors reported: " + errorHandler.errorCounter);
} else {
exit(0, "No error reported.");
}
}
public static void exit(int errCode, String msg) {
System.out.println(msg);
System.exit(errCode);
}
}
--------------------------------------------------------------------------
% java -showversion -cp . test.LoadSchema mgS005.xsd
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b38)
Java HotSpot(TM) Server VM (build 1.5.0-beta2-b38, mixed mode)
No error reported.
--------------------------------------------------------------------------
======================================================================