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: Element Declarations Consistent"
defined in section "3.8.6 Constraints on Model Group Schema Components"
of XML Schema 1.0 Structures spec :
If the {particles} contains, either directly, indirectly (that is, within
the {particles} of a contained model group, recursively) or ?implicitly?
two or more element declaration particles with the same {name} and {target
namespace}, then all their type definitions must be the same top-level
definition, that is, all of the following must be true:
1 all their {type definition}s must have a non-?absent? name.
2 all their {type definition}s must have the same name.
3 all their {type definition}s must have the same target namespace.
See the sample and log below. Test schemas of the affected JCK 15 tests contain
definitions like:
<xsd:sequence>
<xsd:element name="e1" type="xsd:string"/>
<xsd:element name="e1" type="xsd:integer"/>
</xsd:sequence>
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/mgR001.html#mgR001
api/xml_schema/msxsdtest/ModelGroups/mgR002.html#mgR002
api/xml_schema/msxsdtest/ModelGroups/mgR003.html#mgR003
api/xml_schema/msxsdtest/ModelGroups/mgR006.html#mgR006
api/xml_schema/msxsdtest/ModelGroups/mgR007.html#mgR007
api/xml_schema/msxsdtest/ModelGroups/mgR008.html#mgR008
api/xml_schema/msxsdtest/ModelGroups/mgR009.html#mgR009
api/xml_schema/msxsdtest/ModelGroups/mgR014.html#mgR014
api/xml_schema/msxsdtest/ModelGroups/mgR015.html#mgR015
api/xml_schema/msxsdtest/ModelGroups/mgR016.html#mgR016
api/xml_schema/msxsdtest/ModelGroups/mgR017.html#mgR017
api/xml_schema/msxsdtest/ModelGroups/mgR018.html#mgR018
api/xml_schema/msxsdtest/ModelGroups/mgR019.html#mgR019
api/xml_schema/msxsdtest/ModelGroups/mgR020.html#mgR020
api/xml_schema/msxsdtest/ModelGroups/mgR021.html#mgR021
api/xml_schema/msxsdtest/ModelGroups/mgR022.html#mgR022
---- mgR001.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:all>
<xsd:element name="e1" type="xsd:string"/>
<xsd:element name="e1" type="bar"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="bar">
<xsd:sequence>
<xsd:choice>
<xsd:choice>
<xsd:element name="e1" type="xsd:string"/>
</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 mgR001.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: Element Declarations Consistent"
defined in section "3.8.6 Constraints on Model Group Schema Components"
of XML Schema 1.0 Structures spec :
If the {particles} contains, either directly, indirectly (that is, within
the {particles} of a contained model group, recursively) or ?implicitly?
two or more element declaration particles with the same {name} and {target
namespace}, then all their type definitions must be the same top-level
definition, that is, all of the following must be true:
1 all their {type definition}s must have a non-?absent? name.
2 all their {type definition}s must have the same name.
3 all their {type definition}s must have the same target namespace.
See the sample and log below. Test schemas of the affected JCK 15 tests contain
definitions like:
<xsd:sequence>
<xsd:element name="e1" type="xsd:string"/>
<xsd:element name="e1" type="xsd:integer"/>
</xsd:sequence>
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/mgR001.html#mgR001
api/xml_schema/msxsdtest/ModelGroups/mgR002.html#mgR002
api/xml_schema/msxsdtest/ModelGroups/mgR003.html#mgR003
api/xml_schema/msxsdtest/ModelGroups/mgR006.html#mgR006
api/xml_schema/msxsdtest/ModelGroups/mgR007.html#mgR007
api/xml_schema/msxsdtest/ModelGroups/mgR008.html#mgR008
api/xml_schema/msxsdtest/ModelGroups/mgR009.html#mgR009
api/xml_schema/msxsdtest/ModelGroups/mgR014.html#mgR014
api/xml_schema/msxsdtest/ModelGroups/mgR015.html#mgR015
api/xml_schema/msxsdtest/ModelGroups/mgR016.html#mgR016
api/xml_schema/msxsdtest/ModelGroups/mgR017.html#mgR017
api/xml_schema/msxsdtest/ModelGroups/mgR018.html#mgR018
api/xml_schema/msxsdtest/ModelGroups/mgR019.html#mgR019
api/xml_schema/msxsdtest/ModelGroups/mgR020.html#mgR020
api/xml_schema/msxsdtest/ModelGroups/mgR021.html#mgR021
api/xml_schema/msxsdtest/ModelGroups/mgR022.html#mgR022
---- mgR001.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:all>
<xsd:element name="e1" type="xsd:string"/>
<xsd:element name="e1" type="bar"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="bar">
<xsd:sequence>
<xsd:choice>
<xsd:choice>
<xsd:element name="e1" type="xsd:string"/>
</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 mgR001.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.
--------------------------------------------------------------------------
======================================================================