java schema 验证_java实现的XMLschema验证是什么?

最近对Schema 验证研究了一下, 代码如下:所需JAR包需要自己下载(版本一定要正确)public class SchemaValidation {    public static void main(String[] args) {        validate();    }    public static void validate() {        try {            SchemaValidation demo = new SchemaValidation();            // Give the xml and schema name            InputStream xmlString = demo。

getClass()。getResourceAsStream("GBAInit。xml");            InputStream schemaStr = demo。getClass()。getResourceAsStream("GBAInitSchema。

xsd");                SAXReader reader = createSAXReader(schemaStr);            System。out。println("XSD parse successfully !");                        Document document = reader。

read(xmlString);            System。out。println("Successfully validation 。。 。 ");        } catch (DocumentException e) {            System。

out。println("Exception occurred: " + e);            Throwable nestedException = e。getNestedException();            if (nestedException != null) {                System。

out。println("NestedException: " + nestedException);                nestedException。printStackTrace();            } else {                e。

printStackTrace();            }        } catch (Throwable t) {            System。out。println("Exception occurred: " + t);            t。

printStackTrace();        }    } 。

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值