Where can I find a Java implementation of an ISO Schematron validator?

后端 未结 4 1745
北恋
北恋 2020-12-30 14:41

The ISO Schematron standard has been out for two years now, but I\'m still unable to find a Java implementation using ISO Schematron XSLT files (as opposed to files from an

4条回答
  •  感情败类
    2020-12-30 15:11

    Additionally you may use ph-schematron which provides both support for conversion to XSLT as well as a native plain Java validation, which is quicker than the XSLT version in nearly all cases. See https://github.com/phax/ph-schematron/ for the details as well as a quick intro. Example code to check if an XML file matches a Schematron file:

    public static boolean validateXMLViaPureSchematron (File aSchematronFile, File aXMLFile) throws Exception { 
      final ISchematronResource aResPure = SchematronResourcePure.fromFile (aSchematronFile);
      if (!aResPure.isValidSchematron ()) 
        throw new IllegalArgumentException ("Invalid Schematron!"); 
      return aResPure.getSchematronValidity(new StreamSource(aXMLFile)).isValid ();
    }
    

提交回复
热议问题