Suppose I have an XML schema .xsd file which has many such <xsd:include schemaLocation="../Common/{dir}" /> elements among other types of xsd:include statements. I am trying to validate an input file in java:
public static void validate(String xml_file, String schema_file, String base_dir) throws
SAXException, IOException {
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
InputStream input_stream = new FileInputStream(schema_file);
((sf.newSchema(new StreamSource(input_stream, base_dir))).newValidator()).validate(new StreamSource(new File(xml_file)));
}
However, I am getting a Cannot find the declaration of element '[element_type]', when that [element_type] is clearly referred to in the schema_file include statements. Is there something I am doing wrong? How can I go about fixing this?