Not bundled with JDK; must install third party library
Can still use javax.xml.validation
API.
public void testRELAXNGValid() {
// some of this might be moved into fixtures
DocumentBuilder parser
= DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(new File("filename.xml"));
SchemaFactory factory
= SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
Source source = new StreamSource(new File("plist.rnc"));
Schema schema = factory.newSchema(source);
Validator validator = schema.newValidator();
validator.validate(new DOMSource(document));
// throws exception if document is invalid
}