DLR-SL / CPACS

CPACS - Common Parametric Aircraft Configuration Schema
http://dlr-sl.github.io/CPACS/
Apache License 2.0
78 stars 38 forks source link

Replace vectorBaseTypes with xsd:list #808

Open MarAlder opened 1 year ago

MarAlder commented 1 year ago

Relates to: #806

In the current CPACS, most vectors are based on the stringVectorBaseType. Some have already been set on a derived doubleVectorBaseType which emulates semicolon-separated elements of type Double via complex regex keys.

The use of regex is not very robust, as it is difficult to impossible to map and validate certain types of data. For example, we cannot validate vectors that contain uID references.

This can be solved by using xsd:list, sometimes in combination with regex. I therefore propose to introduce new vector types (neglecting the annotations). xsd:list vectors are separated by a space. See cpacs4 branch for example files.

Double type vectors:

<xsd:simpleType name="doubleVectorType">
    <xsd:list itemType="xsd:double"/>
</xsd:simpleType>

String vectors:

<xsd:simpleType name="stringVectorType">
    <xsd:list itemType="xsd:string"/>
</xsd:simpleType>

This validates the uID-references in the vector; pretty cool 😏:

<xsd:simpleType name="uidRefVectorType">
    <xsd:list itemType="xsd:IDREF"/>
</xsd:simpleType>

Integer vectors:

<xsd:simpleType name="integerVectorType">
    <xsd:list itemType="xsd:integer"/>
</xsd:simpleType>

The indexVectorType ensures that indices are counting from 1, not from zero. However, this needs to be realized by regex pattern:

<xsd:simpleType name="indexVectorType">
    <xsd:restriction base="xsd:string">
        <xsd:pattern value="([1-9][0-9]*([\s]+[1-9][0-9]*)*)"/>
    </xsd:restriction>
</xsd:simpleType>

Same with restrictions (unless someone finds a better solution at stackoverflow):

<xsd:element name="wayPointType">
    <xsd:simpleType>
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="(flyOver|flyBy)( (flyOver|flyBy))*"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:element>