Name: erR10175 Date: 03/09/2004
The method
public Schema newSchema(File schema)
in the class javax.xml.validation.SchemaFactory does not detect an error
in the following notation declaration:
<xsd:notation name="png"/>
The declaration is invalid because neither 'public' nor 'system' attribute is specified.
The XML Schema Part 1: Structures (Section 3.12.1 The Notation Declaration
Schema Component) reads:
"The notation declaration schema component has the following properties:
...
{system identifier} Optional if {public identifier} is present. A URI reference.
{public identifier} Optional if {system identifier} is present.
A public identifier, as defined in [XML 1.0 (Second Edition)].
"
The Errata E1-16 does not change that wording, it merely changes
the type of the 'public' attribute and sets it optional. With this
correction the spec makes it possible to specify the 'system' attribute
without 'public', but still prohibits to omit both.
The bug affects the following JCK-15 beta2 test:
api/xml_schema/structures/Notation/publicId/publicId00201m/publicId00201m1.html#Negative
The test was excluded from TCK JAXP 1.2 due to #4830474
but the re-evaluation in #4981038 shows that the test is still valid.
The bug is found in jdk1.5.0/beta/b41 and it is not reproducible with jdk1.5.0/beta/b40.
To reproduce the bug compile and run the following code as shown in the log below.
------------------------------------------- test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="publicId"
targetNamespace="publicId">
<xsd:notation name="png"/>
<xsd:element name="a" type="xsd:string" />
</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-b41)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b41, mixed mode)
Failed: test.xsd is valid
----------------------------------------------------
======================================================================
The method
public Schema newSchema(File schema)
in the class javax.xml.validation.SchemaFactory does not detect an error
in the following notation declaration:
<xsd:notation name="png"/>
The declaration is invalid because neither 'public' nor 'system' attribute is specified.
The XML Schema Part 1: Structures (Section 3.12.1 The Notation Declaration
Schema Component) reads:
"The notation declaration schema component has the following properties:
...
{system identifier} Optional if {public identifier} is present. A URI reference.
{public identifier} Optional if {system identifier} is present.
A public identifier, as defined in [XML 1.0 (Second Edition)].
"
The Errata E1-16 does not change that wording, it merely changes
the type of the 'public' attribute and sets it optional. With this
correction the spec makes it possible to specify the 'system' attribute
without 'public', but still prohibits to omit both.
The bug affects the following JCK-15 beta2 test:
api/xml_schema/structures/Notation/publicId/publicId00201m/publicId00201m1.html#Negative
The test was excluded from TCK JAXP 1.2 due to #4830474
but the re-evaluation in #4981038 shows that the test is still valid.
The bug is found in jdk1.5.0/beta/b41 and it is not reproducible with jdk1.5.0/beta/b40.
To reproduce the bug compile and run the following code as shown in the log below.
------------------------------------------- test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="publicId"
targetNamespace="publicId">
<xsd:notation name="png"/>
<xsd:element name="a" type="xsd:string" />
</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-b41)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b41, mixed mode)
Failed: test.xsd is valid
----------------------------------------------------
======================================================================