### Question:
SchematronValidatingParser { public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws Exception { return parse(uc.getInputStream(), instruction, logger); } SchematronValidatingParser();  SchematronValidatingParser(Document schema_link); String getFileType(Element schema_links); InputStream DocumentToInputStream(org.w3c.dom.Document edoc); boolean checkSchematronRules(Document doc, String schemaFile,
            String phase); boolean checkSchematronRulesAdv(InputSource inputDoc,
            File schemaFile, String phase); boolean executeSchematronDriver(InputSource inputDoc,
            File schemaFile, String phase); Document parse(URLConnection uc, Element instruction,
            PrintWriter logger); NodeList validate(Document xmlEntity, String schemaRef, String phase); static final String SCHEMATRON_NS_URI; }### Answer:
@Test public void parseDocumentOk() throws Exception { Writer strWriter = new StringWriter(); PrintWriter writer = new PrintWriter(strWriter); StringBuilder xml = new StringBuilder( "<tep:schemas xmlns:tep='http: xml.append("<tep:schema type='resource' phase='VersionNegotiationFailedPhase'>"); xml.append("/sch/ExceptionReport.sch"); xml.append("</tep:schema></tep:schemas>"); Document instr = docBuilder.parse(new InputSource(new StringReader(xml .toString()))); Document doc = docBuilder.parse(this.getClass().getResourceAsStream( "/exception.xml")); SchematronValidatingParser parser = new SchematronValidatingParser(); Document result = parser.parse(doc, instr.getDocumentElement(), writer); assertNotNull(result); assertTrue("Unexpected error messages.", strWriter.toString().isEmpty()); }
@Test public void parseInputStreamExpectViolations() throws Exception { Writer strWriter = new StringWriter(); PrintWriter writer = new PrintWriter(strWriter); StringBuilder xml = new StringBuilder( "<tep:schemas xmlns:tep='http: xml.append("<tep:schema type='resource' phase='#ALL'>"); xml.append("/sch/csw-capabilities.sch"); xml.append("</tep:schema></tep:schemas>"); Document instr = docBuilder.parse(new InputSource(new StringReader(xml .toString()))); InputStream input = this.getClass().getResourceAsStream( "/capabilities-pycsw.xml"); SchematronValidatingParser parser = new SchematronValidatingParser(); Document result = parser.parse(input, instr.getDocumentElement(), writer); assertNull(result); assertFalse("Expected error messages.", strWriter.toString().isEmpty()); }