XSD:如何重新定义 simpleType 的数据类型,例如.从 xs:string 到 xs:integer [英] XSD: How to redefine the data type of a simpleType eg. from xs:string to xs:integer

查看:37
本文介绍了XSD:如何重新定义 simpleType 的数据类型,例如.从 xs:string 到 xs:integer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展和定制外部 xsd 架构(符合 fixml 标准).我需要改变一些元素的数据类型,而不是触及原始模式,而是通过重新定义它;但一直觉得它非常麻烦.

I am trying to extend and tailor an external xsd schema (of the fixml standard). I need to change the data type of some of the elements, without touching the original schema, but by redefining it; but have been finding it exceedingly cumbersome.

什么存在:

fields-base.xsd

fields-base.xsd

<xs:simpleType name="LastUpdateTime_t">
           <xs:restriction base="UTCTimestamp">
<xs:simpleType>

我想要它变成什么:

<xs:simpleType name="LastUpdateTime_t">
           <xs:restriction base="xs:string">
<xs:simpleType>

我尝试过的(但失败了):

What I have tried (but failed) :

<xs:redefine schemaLocation="fields-base.xsd">
            <xs:simpleType name="LastUpdateTime_t">
              <xs:restriction base="xs:string" />
            </xs:simpleType>
 </xs:redefine>

书籍和网络似乎也没有太大帮助,所以我开始怀疑这在理论上是否可行.

Books and net dont seem to have helped too much either, so I am starting to question if this is theoretically possible at all.

推荐答案

据我所知这是不可能的.

As far as I can tell this is not possible.

我可以在 XMLSpy 中进行验证的唯一重新定义是:

The only redefine I could make validate in XMLSpy was:

<xs:redefine schemaLocation="fields-base.xsd"> 
        <xs:simpleType name="LastUpdateTime_t"> 
          <xs:restriction base="LastUpdateTime_t" /> 
        </xs:simpleType> 
</xs:redefine> 

也就是说,新的限制必须基于基础限制.

That is, the new restriction must be based on the base restriction.

这可能是 XMLSpy 错了.

Could be that XMLSpy is wrong about this.

这个来自 W3C XML 的有点神秘的引用架构定义:

在 [children] 中,每个simpleType 必须有一个在它的 [孩子] 和每个complexType 必须有限制或在其间延伸Grand-[children] 的·实际价值·其基础 [属性] 必须是与其自身的实际价值相同name 属性加上目标命名空间;

Within the [children], each simpleType must have a among its [children] and each complexType must have a restriction or extension among its grand-[children] the ·actual value· of whose base [attribute] must be the same as the ·actual value· of its own name attribute plus target namespace;

可能正在谈论这个(这是 XMLSpy 链接到此错误的规范的一部分).

might be talking about this (it is that part of the spec the XMLSpy links to for this error).

我能找到的重新定义简单类型的唯一很好的例子是 这里.在本例中,重定义仅用于枚举.

The only really good example of redefining simple types I could find was here. In this example, the redefinition is only for enumerations.

这篇关于XSD:如何重新定义 simpleType 的数据类型,例如.从 xs:string 到 xs:integer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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