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

Versioning of datasets #796

Closed MarAlder closed 1 year ago

MarAlder commented 1 year ago

Current situation & problem

We have an update node in CPACS to mark the version history. This can be interpreted differently and contains redundant information (see example below). It is not clear whether the latest version is found in header/version or if this was the initial version with the latest described in header/version/updates/update/version. Furthermore, the parameters timestamp, version and cpacsVersion are redundant.

    <header>
    <name>Basic Wing Model</name>
        <creator>DLR-SL</creator>
        <timestamp>2022-12-04T10:30:00</timestamp>
        <version>1.1</version>
        <cpacsVersion>3.4</cpacsVersion>
        <updates>
            <update>
                <creator>DLR-SL</creator>
                <timestamp>2019-12-04T10:30:00</timestamp>
                <cpacsVersion>3.3</cpacsVersion>
                <version>1.0</version>
                <modification>Create initial data set</modification>
            </update>
            <update>
                <creator>DLR-SL</creator>
                <timestamp>2022-12-04T10:30:00</timestamp>
                <cpacsVersion>3.4</cpacsVersion>
                <version>1.1</version>
                <modification>Updated existing data set to CPACS 3.4</modification>
            </update>
        </updates>
    </header>

Proposal

Data structure

grafik

We propose to provide the latest version of the dataset in header/version. Additional information is given under versionInfos (open for better naming suggestions..). The trick is that version is a reference to the <versionInfo version="..."> attribute. The correspondingversionInfo` element contains all the required information.

    <header>
        <name>Basic Wing Model</name>
        <version>1.1</version>
        <versionInfos>
            <versionInfo version="1.1">
                <creator>DLR-SL</creator>
                <timestamp>2022-10-04T14:13:00</timestamp>
                <description>Updated existing data set to CPACS 3.4</description>
                <cpacsVersion>3.4</cpacsVersion>
            </versionInfo>
            <versionInfo version="1.0">
                <creator>DLR-SL</creator>
                <timestamp>2019-12-04T10:30:00</timestamp>
                <description>Create initial data set</description>
                <cpacsVersion>3.3</cpacsVersion>
            </versionInfo>
        </versionInfos>
    </header>

Technically, this is possible in XSD via key and keyref elements. With this, the dataset is only valid if a versionInfo element matching the upper version entry is found and if each version attribute is unique (similar to uID references).

<xsd:keyref name="versionKeyRef" refer="versionKey">
    <xsd:selector xpath="./header"/>
    <xsd:field xpath="version"/>
</xsd:keyref>
<xsd:key name="versionKey">
    <xsd:selector xpath="./header/versionInfos/*"/>
    <xsd:field xpath="@version"/>
</xsd:key>

Versioning standard

We propose to follow the Semantic Versioning 2.0.0 standard. Theoretically, the corresponding regex strings can be used to enforce this standard (see here and examples).

It seems at the moment that some editors have problems with this. I get error messages with Eclipse that the regex expression is invalid. Here we need to find a solution to work around the problem.

ToDo

MarAlder commented 1 year ago

Regex as proposed by Semantic Versioning 2.0.0 seems not to work with Eclipse. Also other editiors have trouble with this regex. Let's use xsd:string until someone finds a solution.

 ^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$

(see regex101.com)