Discussions

XML & Web services: Problems on validating XML against Schema using JDOM

  1. 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.
  2. xml String (Root Element)
    =================
    <!--?xml version="1.0" encoding="ISO-8859-1" ?-->
    identificador="L00196b6272223b453ed9844a8815ac7f2f9">


    I am wondering if I am doing anything wrong.

    Thanks

    Marcio Nielsen Baptista.
    I don't see the element ending (like /> or .. is that the problem by any chance? Rakesh.