This is the Java method performing this operation public Document generateXercesDOM(String xmlMessage, URL xsdURL) throws URISyntaxException { Document document = null; DOMParser parser = new DOMParser(); try { parser.setFeature("http://xml.org/sax/features/validation",true); parser.setFeature("http://apache.org/xml/features/validation/schema", true); parser.setFeature("http://apache.org/xml/features/validation/schema-full -checking",true); parser.setProperty("http://apache.org/xml/properties/schema/external-noN amespaceSchemaLocation", xsdURL.toURI().toString()); ErrorHandler handler = new ParserErrorHandler(); parser.setErrorHandler(handler); //Validator handler = new Validator(); //parser.setErrorHandler(handler); StringReader str = new StringReader(xmlMessage); System.out.println("==========================================="); parser.parse(new InputSource(str)); System.out.println("*******************************************"); document = parser.getDocument(); System.out.println("This is the Document " + document); } catch (SAXNotRecognizedException e) { System.out.println("This is SAXNotRecognizedException"); e.printStackTrace(); } catch (SAXNotSupportedException e) { System.out.println("This is SAXNotSupportedException"); e.printStackTrace(); }catch (SAXException e) { System.out.println("This is SAXException"); e.printStackTrace(); }catch (IOException e) { System.out.println("This is IOException"); e.printStackTrace(); } return document; }
________________________________ From: Barun Kumar Yadav [mailto:[EMAIL PROTECTED] Sent: Thursday, January 31, 2008 6:11 PM To: j-users@xerces.apache.org Subject: Xerces gives General Schema Error | Works with Oracle Parser Hi All, I am trying to moving from Oracle parse to Xerces Parser. Using the same XSD and XML if I run the code with Oracle Parser it does not give me any error, but when I try it with Xerces it gives me General Schem Error. The error trace is below General Schema Error: Schema in file:/D:/CPNI/Installs/bea/user_projects/w4WP_workspaces/Untitled/Phase2 /resources/config/schema/EDD/jms/Public/test.xsd <file:/D:/CPNI/Installs/bea/user_projects/w4WP_workspaces/Untitled/Phase 2/resources/config/schema/EDD/jms/Public/test.xsd> has a different target namespace from the one specified in the instance document :. org.xml.sax.SAXParseException: General Schema Error: Schema in file:/D:/CPNI/Installs/bea/user_projects/w4WP_workspaces/Untitled/Phase2 /resources/config/schema/EDD/jms/Public/test.xsd <file:/D:/CPNI/Installs/bea/user_projects/w4WP_workspaces/Untitled/Phase 2/resources/config/schema/EDD/jms/Public/test.xsd> has a different target namespace from the one specified in the instance document :. at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213) at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLErr or(XMLValidator.java:1821) at org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XM LValidator.java:2846) at org.apache.xerces.validators.common.XMLValidator.parseSchemas(XMLValidat or.java:2747) at org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElement AndAttributes(XMLValidator.java:2628) at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVal idator.java:1218) at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentSc anner.java:1806) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatc h(XMLDocumentScanner.java:949) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScan ner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at com.att.cpni.common.util.TestXercesParser.generateXercesDOM(TestXercesPa rser.java:33) at com.att.cpni.common.util.CPNIDomParserTest.testIsMandatoryInputAttrPrese nt(CPNIDomParserTest.java:136) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) The XSD I am using is attached with mail. The generated XML that I am using is generated using an XML editor, so I don't expect it to be wrong. <<test.xsd>> Any ideas what could be the cause? Thanks Barun