Name: erR10175 Date: 02/03/2004
The method
public Schema newSchema(File schema) throws SAXException
in the class javax.xml.validation.SchemaFactory does not detect
violation of the following constraint (XML Schema Part 1: Structures,
3.8.6 Constraints on Model Group Schema Components):
"Schema Component Constraint: Unique Particle Attribution
A 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. "
The test (see below) creates a Schema instance for the schema that contains two wildcards
that may validate the same element information item:
<xsd:choice maxOccurs="10">
<xsd:any namespace="A" processContents="lax"/>
<xsd:any namespace="A"/>
</xsd:choice>
According to the wording this schema is invalid, but the RI does not report any error.
The bug affects the following new JCK-15 beta2 tests adopted from W3C XSTC-20020116 testsuite:
api/xml_schema/msxsdtest/wildCards/wildI008.html#wildI008
api/xml_schema/msxsdtest/wildCards/wildI009.html#wildI009
api/xml_schema/msxsdtest/wildCards/wildI010.html#wildI010
api/xml_schema/msxsdtest/wildCards/wildI013.html#wildI013
The bug is found in jdk1.5.0/beta/b35.
To reproduce the bug compile and run the following code as shown in the log below.
------------------------------------------- test.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xsdtesting">
<xsd:element name="foo">
<xsd:complexType>
<xsd:choice maxOccurs="10">
<xsd:any namespace="A" processContents="lax"/>
<xsd:any namespace="A"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="bar"/>
</xsd:schema>
----------------------------------------------------
------------------------------------------ test.java
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 test {
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, "Failed: " + args[0] + " is valid");
} else {
exit(0, "Passed.");
}
}
public static void exit(int errCode, String msg) {
System.out.println(msg);
System.exit(errCode);
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -showversion test test.xsd
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)
Failed: test.xsd is valid
----------------------------------------------------
======================================================================
###@###.### 2004-02-04
The method
public Schema newSchema(File schema) throws SAXException
in the class javax.xml.validation.SchemaFactory does not detect
violation of the following constraint (XML Schema Part 1: Structures,
3.8.6 Constraints on Model Group Schema Components):
"Schema Component Constraint: Unique Particle Attribution
A 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. "
The test (see below) creates a Schema instance for the schema that contains two wildcards
that may validate the same element information item:
<xsd:choice maxOccurs="10">
<xsd:any namespace="A" processContents="lax"/>
<xsd:any namespace="A"/>
</xsd:choice>
According to the wording this schema is invalid, but the RI does not report any error.
The bug affects the following new JCK-15 beta2 tests adopted from W3C XSTC-20020116 testsuite:
api/xml_schema/msxsdtest/wildCards/wildI008.html#wildI008
api/xml_schema/msxsdtest/wildCards/wildI009.html#wildI009
api/xml_schema/msxsdtest/wildCards/wildI010.html#wildI010
api/xml_schema/msxsdtest/wildCards/wildI013.html#wildI013
The bug is found in jdk1.5.0/beta/b35.
To reproduce the bug compile and run the following code as shown in the log below.
------------------------------------------- test.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xsdtesting">
<xsd:element name="foo">
<xsd:complexType>
<xsd:choice maxOccurs="10">
<xsd:any namespace="A" processContents="lax"/>
<xsd:any namespace="A"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="bar"/>
</xsd:schema>
----------------------------------------------------
------------------------------------------ test.java
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 test {
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, "Failed: " + args[0] + " is valid");
} else {
exit(0, "Passed.");
}
}
public static void exit(int errCode, String msg) {
System.out.println(msg);
System.exit(errCode);
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -showversion test test.xsd
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)
Failed: test.xsd is valid
----------------------------------------------------
======================================================================
###@###.### 2004-02-04