【问题标题】:XSD Problem with Type Attribute : The type attribute cannot be present with either simpleType or complexType类型属性的 XSD 问题:类型属性不能与 simpleType 或 complexType 一起出现
【发布时间】:2018-10-11 12:00:37
【问题描述】:

我已经在 stackoverflow 上寻找答案,但不幸的是,所有的分析器都不适合我:

我有以下 xml:

<STGDocument version="3" workitem-id="0" index="1">
       <ID type="String">ab78e02c-a472-45b9-99d0-57c19034a51b</ID>
....

以及从网页生成的 XSD:

<xs:element name="STGDocument">
<xs:complexType>
  <xs:sequence>
    <xs:element name="ID" type="xs:string">
      <xs:complexType>
        <xs:attribute name="type" type="xs:string"></xs:attribute>
      </xs:complexType>
    </xs:element>
.......

&lt;xs:element name "Id" ....&gt; 标记不知何故抛出错误“类型属性不能与 simpleType 或 complexType 一起出现”

我该如何解决这个问题?

如前所述,我在 SOF 上尝试了所有解决方案,但没有一个对我有用...

感谢

【问题讨论】:

  • 我现在删除了 中的 type 属性,现在它报错了,因为 XML 中的 ID 元素包含字符串
  • 现在它抱怨:元素不能包含文本。内容模型为空。'

标签: xml types xsd


【解决方案1】:

元素的类型要么使用type 属性(如type="xs:string")声明,要么使用嵌套的xs:simpleTypexs:complexType 元素声明。你不能两者兼得,这就是它抱怨的原因。

您的 ID 元素的实际类型是“内容简单的复杂类型”,应声明如下:XSD : How to use both value and attribute

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    • 2014-09-18
    • 1970-01-01
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    相关资源
    最近更新 更多