我在哪里可以找到ISO Schematron验证器的Java实现? [英] Where can I find a Java implementation of an ISO Schematron validator?

查看:98
本文介绍了我在哪里可以找到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 ();
}

这篇关于我在哪里可以找到ISO Schematron验证器的Java实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆