xsd - 验证来自外部字典文件的值 [英] xsd - validating values from external dictionary file

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

问题描述

我想为文档定义一个架构,例如:

I would like to define a schema for a document like:

...
<car>
  <make>ford</make>
  <model>mondeo</model>
</car>
...

问题是我想从外部数据字典中限制可能的值(所以福特/蒙迪欧或奥迪/a4 将是制造/型号的有效值,但奥迪/蒙迪欧不会).如果需要添加新的汽车模型,仅外部数据文件会发生变化,但 xsd 架构将保持不变.

the problem is that I would like to constraint possible values (so ford/mondeo or audi/a4 would be valid values for make/model, but audi/mondeo would not) from external data dictionary. In case when new car models needs to be added only external data file would change, but xsd schema would remain the same.

这可能吗?我查看了 key/keyref 约束,我发现我可以在单个文档中使用它们,但这不是我要找的.我不想在每个文档实例中重复完整的数据字典,我宁愿让数据文件构成架构的一部分.

Is this possible at all? I have looked at key/keyref constraint, I see I can use them within a single document, but this is not I'm looking for. I don't want to repeat full data dictionary with every document instance, I would prefer to have the data file rather constitute part of the schema.

推荐答案

这在 XML Schema 1.0 中是不可能的.

That is not possible in XML Schema 1.0.

XML Schema 1.1 将添加一些支持以允许表达此类约束(尽管 AFAIK 不在外部文件中) - 但这还不是 W3C 的建议.

XML Schema 1.1 will add some support that will allow expressing this kind of constraints (although AFAIK not in external files) - but that is not yet a W3C recommendation.

现在可以使用 Schematron 实现这一点,最终嵌入到 XML Schema 中.

It is possible to implement this now with Schematron, eventually embedded in XML Schema.

然而,在这方面已经有一些可用的结果.查看 OASIS 代码列表

However, there was already work in this area with usable results. See OASIS Code Lists

http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=codelist

可以在此处找到更多详细信息:

More details can be found here:

http://www.genericode.org/

这是在 OASIS 通用商业语言 (UBL) 中使用的http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ubl

This is used in the OASIS Universal Business Language (UBL) http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ubl

最好的问候,乔治

这篇关于xsd - 验证来自外部字典文件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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