RISCSoftware / cpacs_tigl_gen

Generates CPACS schema based classes for TiGL
Apache License 2.0
5 stars 5 forks source link

Class generation fails for some simpleType extensions/restrictions #47

Closed MarAlder closed 1 year ago

MarAlder commented 2 years ago

CPACS 3.4 constains some new baseTypes, e.g. posExcl0IntBaseType, which are leading to the following error:

Exception: Unknown type: posExcl0IntBaseType

The xsd specification is as follows:

    <xsd:complexType name="posExcl0IntBaseType">
        <xsd:annotation>
            <xsd:appinfo>
                <sd:schemaDoc>
                    <ddue:summary>
                        <ddue:para>Positive integer values larger than 0</ddue:para>
                    </ddue:summary>
                </sd:schemaDoc>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:simpleContent>
            <xsd:restriction base="integerBaseType">
                <xsd:minExclusive value="0"></xsd:minExclusive>
            </xsd:restriction>
        </xsd:simpleContent>
    </xsd:complexType>

The problem is that the first if-condition (L340) is met, but the second is not (L347). Thus only name is returned without adding the type to m_types: https://github.com/RISCSoftware/cpacs_tigl_gen/blob/65f66ea98a1e7c4368e75e5f80b955a0b7e0aaf8/src/lib/SchemaParser.cpp#L339-L368

I moved return name; into the inner if-condition to avoid an exit of readComplexType before appending m_types. Then, the code generation runs through. Although the generated class looks good and I got some further insight into CPACS-generator through the debugging process, I'm still struggling with some details of the code. Maybe someone can check whether this is a reasonable fix or whether something else needs to be considered.

joergbrech commented 2 years ago

I had the same issue with doubleVectorBaseType in CPACS 3.3.