modelica / fmi-standard

Specification of the Functional Mock-up Interface (FMI)

Home Page:https://fmi-standard.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FMI 3.0 validation fails to validate Enumeration with Annotations in libxml2

t-sommer opened this issue · comments

The validation of the following XML fails in libxml2 2.11.5 using the current schema

    <Enumeration
      name="world.gravityType"
      valueReference="100663316"
      description="Type of gravity field"
      variability="constant"
      declaredType="Modelica.Mechanics.MultiBody.Types.GravityTypes"
      start="2">
      <Annotations>
        <Annotation
          type="com.3ds.dymola">
          <DeclarationOrder
            order="36"/>
        </Annotation>
      </Annotations>
    </Enumeration>

with

ERROR (line 612, column 0): Element 'Annotations': This element is not expected. Expected is ( Alias ).

This seems to be related to the following definition in fmi3Variable.xsd.

    <xs:complexType name="fmi3MandatorilyTypedArrayableVariable" abstract="true">
        <xs:complexContent>
            <xs:restriction base="fmi3TypedArrayableVariable">
                <xs:attribute name="declaredType" type="xs:normalizedString" use="required"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

The validation succeeds when changing it to

    <xs:complexType name="fmi3MandatorilyTypedArrayableVariable" abstract="true">
        <xs:complexContent>
            <xs:extension base="fmi3TypedArrayableVariable">
<!--                <xs:attribute name="declaredType" type="xs:normalizedString" use="required"/>-->
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

@pmai, do you think this is a bug in libxml2?

A possible workaround would be to let fmi3Enumeration extend fmi3TypedArrayableVariable directly and check for the declaredType attribute programmatically.

It seems to me you are using an obsolete version of the schema, since this seems to be the exact case that #1838 fixed, w.r.t. issue #1837?

I.e. in current head (and hence 3.0.1, i guess) the schema for fmi3MandatorilyTypedArrayableVariable is

    <xs:complexType name="fmi3MandatorilyTypedArrayableVariable" abstract="true">
        <xs:complexContent>
            <xs:restriction base="fmi3TypedArrayableVariable">
                <xs:sequence>
                    <xs:element ref="Annotations" minOccurs="0"/>
                    <xs:group ref="fmi3Dimensions"/>
                </xs:sequence>
                <xs:attribute name="declaredType" type="xs:normalizedString" use="required"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

and not

 <xs:complexType name="fmi3MandatorilyTypedArrayableVariable" abstract="true">
        <xs:complexContent>
            <xs:restriction base="fmi3TypedArrayableVariable">
                <xs:attribute name="declaredType" type="xs:normalizedString" use="required"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

as it was for 3.0.0...