我在哪里可以找到ISO Schematron验证器的Java实现?

问题描述:

ISO Schematron标准已经出现两年了,但我仍然无法使用ISO Schematron XSLT文件找到Java实现(而不是旧版Schematron中的文件,例如: http://uploading.com/files/c9c9cb87/SchematronXpath.jar/ )。

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 older version of Schematron, e.g. here: http://uploading.com/files/c9c9cb87/SchematronXpath.jar/).

有没有人知道可以从Java方法轻松调用的生产就绪ISO模式验证器?

Does anyone know of a production-ready ISO schema validator that can be easily called from a Java method?

此外,您可以使用 ph-schematron ,它既提供对转换到XSLT的支持,也提供本机普通Java验证,这比XSLT更快几乎在所有情况下的版本。
有关详细信息,请参见 https://github.com/phax/ph-schematron/ 快速介绍。
检查XML文件是否与Schematron文件匹配的示例代码:

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 ();
}