Deepal Jayasinghe provides example code for XML Schema Document validation:

If you are looking for a tool to validate your XSD against the http://www.w3.org/2001/XMLSchema.xsd Then you can build your own tool using the following code.

An alternative would be XMLUnit's svn trunk and the following code

import org.custommonkey.xmlunit.jaxp13.Validator;

        Validator v = new Validator();
        v.addSchemaSource(new StreamSource(new File(...)));
        assertTrue(v.isSchemaValid());

XMLUnit 1.2 with support for javax.xml.validation (which Deepal uses as well) shouldn't be too far away.

In theory this should work for Relax NG as well, for a reality check see this.

path: /en/oss/XMLUnit | #