XML & Web services: Problems on validating XML against Schema using JDOM
Hi, I am trying to validate a xml against schema. I have successfully validated the xml against the schema in XMLSpy. But when i am trying to validate it in my java code using JDOM, it is giving me the following error: "org.jdom.input.JDOMParseException: Error on line 1: cvc-elt.1: Cannot find the declaration of element 'Mensagem'." I am using the following code: SAXBuilder sb = new SAXBuilder("org.apache.xerces.parsers.SAXParser"); sb.setValidation(true); sb.setFeature("http://apache.org/xml/features/validation/schema", true); sb.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", "http://localhost:8988/gofer/gofer.xsd"); this.setDocumentoXML( sb.build( new StringReader(valorParam) ) ); gofer.xsd (Root Element): ================= xml String (Root Element) ================= <?xml version="1.0" encoding="ISO-8859-1" ?> I am wondering if I am doing anything wrong. Thanks Marcio Nielsen Baptista.
- Posted by: Marcio Nielsen Baptista
- Posted on: November 08 2006 12:52 EST
- Re: Problems on validating XML against Schema using JDOM by Rakesh Malpani on November 15 2006 12:16 EST
xml String (Root Element)I don't see the element ending (like /> or .. is that the problem by any chance? Rakesh.
<?xml version="1.0" encoding="ISO-8859-1" ?>
I am wondering if I am doing anything wrong.
Marcio Nielsen Baptista.