XML Meta Schema

时光怂恿深爱的人放手 提交于 2019-12-11 15:44:11

问题


Since XML schemata (XSD) are themselves XML files, it should be possible to build a schema of a schema (meta-schema), right?

I'm struggling to accomplish that feat.

I would like to create a schema that describes a schema with one root complexType containing a sequence of simpleTypes.


回答1:


Akoma-Ntoso is an example of such a meta-schema:

"We can say that Akoma Ntoso is a meta-schema that allows you to build your own schema: it provides the building blocks for different organisations to use to build their own very individual schemas. Having organisations using similar building blocks, identifying these blocks in a similar fashion goes a long way to allow greater integration and exchange of documents as well as reusability of software tools..."

Akoma Ntoso (“linked hearts” in the Akan language of West Africa) defines a set of simple technology-neutral electronic representations in XML format of parliamentary, legislative and judiciary documents.

It uses two abstractions, extends:

The element extends is a metadata element specifying a reference to a source extended by the argument being described.

  • an extension is a derived rule that adds in a controlled way new features to a base rule, so that all documents that are correct according to the derived rule can be validated against the base rule by removing the additional features. The set of valid documents according to the derived rule is a controlled superset of the set of valid documents according to the base rule.

and restricts:

The element restricts is a metadata element specifying a reference to a source restricted by the argument being described.

  • a restriction is a derived rule that is stricter than the base one, so that all documents that are correct according to the derived rule are also valid according to the base one: the set of valid documents for the derived rule is a mathematical subset of the set of valid documents according to the base rule.

References

  • Akoma Ntoso | Akoma Ntoso Site

  • Akoma Ntoso Version 1.0 Part 1: XML Vocabulary

  • Akoma Ntoso Version 1.0. Part 2: Specifications

  • AKOMA NTOSO Technical Documentation - Alphabetical Listing

  • XMLSchema Documentation browser: Akoma Ntoso

  • Customizing Akoma Ntoso - Prof. Fabio Vitali University of Bologna (pdf)

  • The Systems Biology Markup Language (SBML): Language Specification for Level 3 Version 1 Core

  • How to verify that one XSD schema is a subset of another XSD schema?




回答2:


So, you want to write an XSD to validate that an XSD is valid? Well, why do that when there is an Xsd Validator:

http://www.w3.org/2001/03/webdata/xsv




回答3:


Of course you can build your own schema for this purpose. A good startingpoint would be the official one from the W3C

I would suggest do make two validation runs: one with the unchanged schema and a second run with a simplified, custom made schema. This custom schema can be a stripped-down version of the original only containing the additional constraints. The rest can be allowed via wildcards (<xs:any>)



来源:https://stackoverflow.com/questions/3051770/xml-meta-schema

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!