I have an xml and an xsd file. Inside the xml file I have given the xsd name.
xsi:schemaLocation="http://www.orc.com/mrb/schemas Invoice.xsd">
When I am parsing the xml using SAX parser I am getting the following error >
> XML-20149: (Error) Element 'InvList' used but not declared.
Isn't it enough to mention the xsd file in xml enough to find the definitions.
Following is the code
InputSource source = null;
String inputFile = null;
File xmlFile = null;
InputStream is = null;
SAXParser saxParser = null;
SAXParserFactory sPF = SAXParserFactory.newInstance();
sPF.setFeature("http://xml.org/sax/features/validation", true);
sPF.setNamespaceAware(true);
sPF.setXIncludeAware(false);
saxParser = sPF.newSAXParser();
try {
SAXParser saxParser = MyUtils.getSAXParser();
XMLReader parser = saxParser.getXMLReader();
parser.setContentHandler(this);
parser.setErrorHandler(this);
inputFile = new String("InvoiceTmp.xml");
xmlFile = new File(inputFile);
is = new FileInputStream(xmlFile);
source = new InputSource(is);
parser.parse(source);
} catch (Exception e) {
MyLog.log(ErrorLog.Error, "Error while parsing XML #1 \n" + e.getMessage());
}