Fair enough ...

In that case, you could use the org.dom4j.io.DocumentInputSource and do 
something like this:

public void validate( Document document) throws ...  {
  SAXParserFactory factory = SAXParserFactory.newInstance();
  factory.setValidating( true);
  factory.setNamespaceAware( true);  

  SAXParser parser = factory.newSAXParser();
  parser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
                              "http://www.w3.org/2001/XMLSchema";);
  parser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaSource";,
                              "file:test.xsd");

  parser.getXMLReader().parse( new DocumentInputSource( document));
}

Or use the org.dom4j.io.SAXValidator class:

public void validate( Document document) throws ...  {
  SAXParserFactory factory = SAXParserFactory.newInstance();
  factory.setValidating( true);
  factory.setNamespaceAware( true);  
  
  SAXParser parser = factory.newSAXParser();
  parser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
                              "http://www.w3.org/2001/XMLSchema";);
  parser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaSource";,
                              "file:test.xsd");

  SAXValidator validator = new SAXValidator( parser.getXMLReader());
  validator.validate( document);
}

Regards,
Edwin

http://www.edankert.com/


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to