Does anybody know if this is a bug or a feature or I am missing something?

I am validating xml against my schema.
If I pass in an unrelated xml message, it fails the schema validation as 
expected.
But if I add a DOCTYPE declaration to the xml message, it PASSES the schema 
validation! (no error was reported)

Details are as follows:

Xerces version: 2.11.0 (class org.apache.xerces.jaxp.validation.ValidatorImpl)

Sample xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
<xs:element name="testRoot" type="xs:string"/>
</xs:schema>

Sample xml: Please note that the root element is not defined in the xsd and is 
different from the name in DOCTYPE. But it PASSED schema validation!
<?xml version="1.0"?>
<!DOCTYPE pond []>
<diffRoot 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>string</diffRoot>


Sample Java code:
       SchemaFactory factory = 
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

       schema = factory.newSchema(schemaURL);

       Validator validator = schema.newValidator();
       validator.setErrorHandler(new CustomHandler());

       validator.validate(new StreamSource(xmlFile));

Joe

Reply via email to