如何指示需要架构 1.1 功能的 xml 架构? [英] How to indicate that an xml schema that requires schema 1.1 features?

查看:23
本文介绍了如何指示需要架构 1.1 功能的 xml 架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建一个 XML Schema 需要 schema 1.1 特性(特别是微妙的特性,比如删除基本类型限制中的可选元素),最好的方法是指示这个 schema 不应该与处理器一起使用只懂 1.0 版?

If I create an XML Schema that requires schema 1.1 features (especially subtle ones, like removing an optional element in restriction of a base type), what is the best way to indicate that this schema should not be used with a processor that only understands version 1.0?

在 XSLT 样式表文件中,可以使用 version 属性指示使用的 XSLT 规范的版本.

In an XSLT stylesheet file, it is possible to indicate the version of the XSLT specification that is used using a version attribute.

但是在 XSD 文件中,version 属性没有这个含义——它是一个自由格式的属性,它说明了架构的版本,而不是规范的版本正在使用中.

But in an XSD file, the version attribute does not have this meaning - it is a free-form attribute that says something about the version of the schema, not about the version of the specification that is being used.

是否需要标记使用 1.1 功能的架构?

And is it required to label a schema that uses 1.1 features?

我有一组使用 FPML 5.5 规范和一些自定义架构的复杂架构,并且无法使用某些架构验证器对其进行验证,但我不确定这是因为验证器有错误还是因为架构巧妙使用 xml 架构 1.1 功能.

I have a complex set of schemas using the FPML 5.5 specification and some custom schemas, and it cannot be validated with some schema validators, but I'm not sure if that is because the validator has bugs or because the schema is subtly using xml schema 1.1 features.

推荐答案

此时,这个问题并不是那么容易解决;这是因为大多数 XSD 处理器都是 1.0,并且 XSD 1.1 规范中引入的模式版本控制不能向后应用.要了解有关它的更多信息(一般而言),请查看架构版本命名空间,以及4.2.2 条件包含部分中包含的示例.

At this point in time, this issue is not that easy to resolve; this is because most of the XSD processors are 1.0, and the schema versioning introduced in XSD 1.1 spec can't apply backwards. To learn more about it (in general) have a look at The Schema Versioning Namepsace, and the examples included in section 4.2.2 Conditional inclusion.

您可以实现自己的预处理解决方案,即至少有助于使用以下内容选择合适的 XSD 处理器:

You could implement your own pre-processing solution, that is to at least help with choosing the appropriate XSD processor using something such as this:

<?xml version="1.0" encoding="utf-8" ?>
<!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning">

    <xsd:element name="e" vc:minVersion="1.1">
        <xsd:complexType>
            <xsd:all>
                <xsd:element name="a" minOccurs="0"/>
                <xsd:element name="b" maxOccurs="unbounded"/>       
            </xsd:all>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="e" vc:minVersion="1.0" vc:maxVersion="1.1">
        <xsd:complexType>
            <xsd:choice maxOccurs="unbounded">
                <xsd:element name="a" minOccurs="0"/>
                <xsd:element name="b" />            
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>      
</xsd:schema>

这样至少您将使用 XSD 1.1 认可的版本控制方法;它还带有一个处理模型.对于某些任务,建立预处理器至少将处理适当的XSD处理器(1.0或1.1)的应用相对容易.为了在封闭环境中更简单,您还可以选择一个约定,您可以在其中使用 vc:minVersion="1.1" 标记整个 xsd:schema - 基本上是您似乎想要开始的.

This way at least you'll be using an XSD 1.1 endorsed approach to versioning; it also comes with a processing model. For certain tasks, it is relatively easy to build a pre-processor that at least will handle the appropriate selection of the XSD processor (1.0 or 1.1) . To make simpler in a closed environment, you could also choose a convention where you could mark the whole xsd:schema with vc:minVersion="1.1" - basically what you seem to have wanted to begin with.

关于您的最后一段,XSD 处理器的选择必须是断言而不是暗示.这是因为 XSD 1.1 允许 XSD 1.0 中不可能的构造(例如,all 合成器包含最大出现次数大于 1 的粒子)......所以除非事先做出决定:处理器使用时,XSD 可能无效,也可能无效.而无论使用何种处理器,其他内容都将无效.

Regarding your last paragraph, the choice of the XSD processor has to be asserted rather than implied. This is because XSD 1.1 allows for constructs that were impossible in XSD 1.0 (e.g. an all compositor containing particles with max occurrence greater than 1)... so unless one makes a prior decision re: the processor to use, the XSD may or may not be invalid. Whereas other things will be invalid regardless of the processor used.

这篇关于如何指示需要架构 1.1 功能的 xml 架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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