验证XSD本身 [英] Validating XSD itself

查看:43
本文介绍了验证XSD本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何验证XSD文件本身(而不是针对XSD的XML)吗?我已经检查了许多论坛和站点(包括SO),其中大多数都引用了某些或其他在线验证器.但这对我们来说不是一次检查.我们的应用程序涉及使用XSD的XSL转换,因此我们需要确定要使用的XSD本身是否为有效格式,例如,所有标签都以开始和结束处匹配.某些标签不允许作为子标签,等等.这就是为什么我们需要适当的Java代码才能实现相同的目的.

Could anyone please tell me how to validate an XSD file itself (not XML against XSD)? I have checked many forums and sites (including SO) and most of them refers some or the other online validator. But this is not a one-time check for us. Our application involves an XSL transformation using an XSD, so we need to determine whether the XSD to be used is itself in a valid format or not, as in, all the tags match, with a starting and a closing one. Certain tags aren't allowed as a child tag, etc. That's why we need a proper java code to achieve the same.

任何帮助将不胜感激.

推荐答案

您可以尝试javax.xml.validation包

You can try javax.xml.validation package

SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema s = f.newSchema(new File("1.xsd"));

Schema.newSchema()API

Schema.newSchema() API

Parses the specified File as a schema and returns it as a Schema

这篇关于验证XSD本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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