[ http://issues.apache.org/jira/browse/XERCESJ-1065?page=all ]
Michael Glavassevich reassigned XERCESJ-1065:
---------------------------------------------
Assign To: Michael Glavassevich
> "Upwards" inheritance of properties with schema include
> -------------------------------------------------------
>
> Key: XERCESJ-1065
> URL: http://issues.apache.org/jira/browse/XERCESJ-1065
> Project: Xerces2-J
> Type: Bug
> Components: XML Schema datatypes
> Versions: 2.6.2
> Environment: Windows XP
> J2sdk1.4.2_06
> Reporter: Ole Hougaard
> Assignee: Michael Glavassevich
> Priority: Critical
>
> 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 {
> throw exception;
> }
> 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 {
> XMLReader parser =
> XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
> URL schemaUrl = XercesTest.class.getResource("/test.xsd");
>
> parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
> "http://w3c.org/test " + schemaUrl);
> parser.setFeature("http://xml.org/sax/features/validation", true);
>
> parser.setFeature("http://apache.org/xml/features/validation/schema", true);
> parser.setContentHandler(contentHandler);
> parser.setErrorHandler(errorHandler);
> parser.parse(new
> InputSource(XercesTest.class.getResourceAsStream("/test.xml")));
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]