简体   繁体   中英

Validating XSD itself

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.

Any help would be highly appreciated.

You can validate an XSD file against the w3 XSD schema that can be found here .

Use the same validation techniques you validate any other XML file with an XSD file, only the source document would be your XSD file.

You can validate your XSD online here .

Just copy and paste your XSD here and click on validate Schema , it will give you the result.

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

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

您可以使用xmllint:

xmllint --noout --dtdvalid http://www.w3.org/2001/XMLSchema.dtd my-schema.xsd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM