Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
2.6.2
-
None
-
None
-
Windows XP
J2sdk1.4.2_06
Description
I've observed this behaviour of XML Schemas: When an abstract complexType extends a concrete complexType, the latter is treated as abstract as well. This only occurs when the concrete type is defined in another file that is included into the schema.
This is reproduced in the following schema files.
Base.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://w3c.org/test"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://w3c.org/test">
<xs:complexType name="Base" abstract="false"/>
</xs:schema>
test.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://w3c.org/test"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://w3c.org/test">
<xs:include schemaLocation="Base.xsd"/>
<xs:complexType name="Derived" abstract="true">
<xs:complexContent>
<xs:extension base="Base"/>
</xs:complexContent>
</xs:complexType>
<xs:element name="base" type="Base"/>
</xs:schema>
The validation of the file test.xml below fails with cvc-type.2: The type definition cannot be abstract for element base.
test.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<base xmlns="http://w3c.org/test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
I'm using the follwing code to validate the schema.
XercesTest.java:
public class XercesTest {
private static final ContentHandler contentHandler = new ContentHandler() {
public void endDocument() {
}
public void startDocument() {
}
public void characters(char[] ch, int start, int length) {
}
public void ignorableWhitespace(char[] ch, int start, int length) {
}
public void endPrefixMapping(String prefix) {
}
public void skippedEntity(String name) {
}
public void setDocumentLocator(Locator locator) {
}
public void processingInstruction(String target, String data) {
}
public void startPrefixMapping(String prefix, String uri) {
}
public void endElement(String namespaceURI, String localName, String qName) {
}
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
}
};
private static final ErrorHandler errorHandler = new ErrorHandler() {
public void error(SAXParseException exception) throws SAXException
public void fatalError(SAXParseException exception) throws SAXException { throw exception; }
public void warning(SAXParseException exception)
{ exception.printStackTrace(); }};
public static void main(String[] args) throws Throwable {
try
catch (Exception e)
{ e.printStackTrace(); } }
}