title: xml validation against xsd by using spring java
body: <p>/<em>i am facing problem because i have three referenced xsd and i to validate a xml which is comming as jdom element. exception i am getting is "cannot find the declearation ". code is given below: 
  Input parameter is : Element param</em>/</p>
  
  <pre><code>     DOMOutputter outputter = new DOMOutputter();
      org.jdom2.Document document=new org.jdom2.Document();
      document.addContent(param.clone());
  org.w3c.dom.Document doc=outputter.output(document);
  
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      Source xmlSource = new DOMSource(doc);
      Result outputTarget = new StreamResult(outputStream);
      TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
      InputStream xml = new ByteArrayInputStream(outputStream.toByteArray()); 
  
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();   
      DocumentBuilder builder;   
      factory.setNamespaceAware(true);
      builder = factory.newDocumentBuilder();
  
      SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      // create a grammar object.
      Source[] source = {
              new StreamSource(new File("H:/ref2.xsd")),
              new StreamSource(new File("H:/ref1.xsd")),
              new StreamSource(new File("H:/ref.xsd"))};
      Schema schemaGrammar = schemaFactory.newSchema(source);
      validator.validate(new StreamSource(xml));
  </code></pre>
  
  <p>//please suggest</p>