【问题标题】:s4s-elt-invalid-content: Element 'attributeGroup' is invalids4s-elt-invalid-content:元素“attributeGroup”无效
【发布时间】:2018-02-17 18:02:38
【问题描述】:

我即将分叉一个现有的 XSD,但是,在接触它之前,我希望有一个工作工具链。进入 Eclipse。

有问题的 XSD 是: http://aixm.aero/schema/4.5/index.html

架构“AIXM-Features.xsd”是根据this online tool 和xmllint 有效的架构:

$ xmllint --schema XMLSchema.xsd AIXM-Features.xsd --noout
AIXM-Features.xsd validates

但是,当我使用 Eclipse 对其进行验证时,每次出现 34 次时都会出现以下行错误:

<xsd:attributeGroup ref="Changes"/>

这是第一个验证错误:

Description Resource Path Location Type s4s-elt-invalid-content.1:
The content of 'AircraftClassType' is invalid.
> Element 'attributeGroup' is invalid, misplaced, or occurs too often.
AIXM-Features.xsd /afmx line 919 XML Schema Problem

知道这里发生了什么吗?

顺便说一句:Eclipse 使用基于 Xerces 的模式验证器。

【问题讨论】:

    标签: xml eclipse xsd xsd-validation xerces


    【解决方案1】:

    显然 AIXM-Features.xsd 不是为了直接单独使用而编写的。如您所见,它引用了 Changes 属性组,但没有定义它或包含它的任何定义。

    请注意,AIXM-Snapshot.xsd 将其定义为没有属性,

    <xsd:attributeGroup name="Changes"/>
    

    而 AIXM-Update.xsd 对它的定义不同,

    <xsd:attributeGroup name="Changes">
        <xsd:attribute name="chg" type="xsd:boolean" use="optional"/>
    </xsd:attributeGroup>
    

    如果你要添加

    <xsd:include schemaLocation="AIXM-Update.xsd"/>
    

    到 AIXM-Features.xsd,错误就会消失。或者,您可以定义一个包含 AIXM-Features.xsd 和 AIXM-Update.xsd 的包装器 XSD。

    最后说明:您引用的错误信息过于宽泛。是的,“无效”可能适用,但实际上更好的诊断会指定引用的 Changes 无法解析为属性组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多