【发布时间】:2021-08-17 08:37:28
【问题描述】:
我有一个外部 xsd,我想创建一个有效的 xml。 xsd 包含一个复杂的类型定义:
<xsd:complexType name="STE_SomeType" abstract="true">
<xsd:simpleContent>
<xsd:extension base="xsd:string"/>
</xsd:simpleContent>
</xsd:complexType>
问题是,在创建 xml 时没有可以使用扩展 STE_SomeType 的非抽象类型。因此,如果我使用以下命令创建 xml:
<Foo xmlns:dat="http://www.example.com/namespace/datatype" xsi:type='dat:STE_SomeType'>abc</Foo>
我收到一个验证错误“错误:(48, 89) cvc-type.2: 元素 Foo 的类型定义不能是抽象的。” 而且我只是不知道我需要提供什么作为 xsi:type 才能获得有效的 xml,因为 xsd 中没有合适的复杂类型。
有没有办法使用 STE_SomeType 具有 simpleContent xsd:string 的事实 或者我可以在 xml 中定义类似“私有类型”扩展 STE_SomeType 的东西吗?
【问题讨论】:
标签: xml validation types xsd abstract