Code example for Schema

Methods: newValidator

0
        } 
 
        // This may throw a SAX Exception if the schema itself is not a valid XSD 
        Schema schema = factory.newSchema(new StreamSource(xsdStream));
 
        Validator validator = schema == null ? null : schema.newValidator();
 
        return validator;
    } 
 
    /** 
     * Takes an XML document as a string as parameter and returns a DOM for it. 
     * 
     * On error, returns null and prints a (hopefully) useful message on the monitor. 
     */ 
    @VisibleForTesting(visibility=Visibility.PRIVATE) 
    protected Document getDocument(InputStream xml, ITaskMonitor monitor) {
        try { 
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setIgnoringComments(true);
            factory.setNamespaceAware(true);