problem to validate XML document if the type of root element is abstract
I have the following XML document:
<?xml version="1.0" encoding="UTF-8"?>
<ct013/>
It corresponds to the following XSD Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ct013" type="foo"/>
<xs:complexType abstract="true" name="foo"/>
<xs:complexType name="fixedType">
<xs:complexContent>
<xs:restriction base="foo"/>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Please take attention to the fact that the type of root element of that BDD is abstract.
XML Schema provides a mechanism to force substitution for a particular element or type. When an element or type is declared to be "abstract", it cannot be used in an instance document. When an element is declared to be abstract, a member of that element's substitution group must appear in the instance document. When an element's corresponding type definition is declared as abstract, all instances of that element must use xsi:type to indicate a derived type that is not abstract.
Declaring an element as abstract requires the use of a substitution group. Declaring a type as abstract simply requires the use of a type derived from it (and identified by the xsi:type attribute) in the instance document.
For more information of using abstract types please see chapter 4.7 Abstract Elements and Types of XML Schema Part 0: Primer Second (http://www.w3.org/TR/xmlschema-0/#abstract).
In this case there is Oracle bug when I try to validate this XML document using Oracle XDK:
String validate(String xml, String schema)
throws XSDException, XMLParseException, SAXException, IOException
{
System.setPropert("oracle.xml.parser.debugmode", "true");
XSDValidator xsdValidator = new XSDValidator();
XMLError xmlError = new XMLError();
xmlError.setErrorHandler(new DocErrorHandler());
XMLDocument xmlDocument = parseXMLDocument(xml);
XMLDocument schemaXMLDocument = parseXMLDocument(schema);
XMLSchema xmlSchema = (XMLSchema) new XSDBuilder().build(schemaXMLDocument, null);
xsdValidator.setError(xmlError);
xsdValidator.setSchema(xmlSchema);
xsdValidator.validate(xmlDocument);
return getValidationError(xsdValidator);
}
I get the following error:
Can't find resource for bundle oracle.xml.mesg.XMLResourceBundle, key XSD-2046.
I tried to validate this XML document using two other libraries - XSD Schema Validator (http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx) and xsdvalid-29 (http://www.w3.org/XML/Schema#XSDValid). Both libraries pointed me on the error that the type of root element is abstract and it cannot be used for doing validation.
I think that Oracle should return me explaining message but not to throw exception.
Am I right? Is there really Oracle bug or I miss something?
Any help, hits, advices would be gratfully apriciated.