Search code examples
xmleclipsexsdxsd-validationxerces

s4s-elt-invalid-content: Element 'attributeGroup' is invalid


I'm about to fork an existing XSD, however, before touching it, I'd like to have a working toolchain. Enter Eclipse.

The XSD in question are: http://aixm.aero/schema/4.5/index.html

The schema "AIXM-Features.xsd" is schema valid according to this online tool as well as xmllint:

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

When I validate it with Eclipse, however, the following line errors on every of its 34 occurrences:

<xsd:attributeGroup ref="Changes"/>

Here's the first validation error:

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

Any idea what's going on here?

BTW: Eclipse uses a Xerces-based schema validator.


Solution

  • Apparently AIXM-Features.xsd is not written to be used directly alone. As you've seen, it references a Changes attribute group without defining it or including any definitions of it.

    Note that AIXM-Snapshot.xsd defines it to have have no attributes,

    <xsd:attributeGroup name="Changes"/>
    

    and AIXM-Update.xsd defines it differently,

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

    If you were to add

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

    to AIXM-Features.xsd, the error would go away. Alternatively, you could define a wrapper XSD that includes both AIXM-Features.xsd and AIXM-Update.xsd.

    Final note: The error message that you cite is overly broad. Yes, "invalid" arguably applies, but really a better diagnostic would specify that the referenced Changes could not be resolved to an attribute group.