w3c / wot-thing-description-toolchain-tmp

work area for WoT Thing Description toolchain
0 stars 1 forks source link

Slots reused in different parts of the LinkML schema #21

Open mahdanoura opened 2 months ago

mahdanoura commented 2 months ago

The aim of slotdefinitions in LinkML is to reuse those entities across the schema. However, some of the slots need to be used in different ways with different properties, for instance the slot title is not mandatory on all TD levels and only on the top level it is required. This is the case for many of the slots defined and causes problems in the generators.

danielpeintner commented 1 month ago

As mentioned in yesterdays TD call I understand the desire to use slot for modelling the same concept once and reusing it.

Anyhow, once the cardinality differs it is not the same concept anymore, if I understand the concept of slot correctly.

I would guess (but I don't know LinkML) there are other ways as well (separating the type and the actual element with occurrences). Let me use XML schema as an example:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <!-- Type to be reused -->
    <xs:complexType name="MyType">
        <xs:sequence>
            <xs:element name="foo" type="xs:string" />
            <xs:element name="bla" type="xs:int" />
        </xs:sequence>
    </xs:complexType>

    <!-- example where type is used  -->
    <xs:element name="root">
        <xs:complexType>
            <xs:sequence>
                <!-- instance with 0 to 10 -->
                <xs:element name="useOfTypeA" type="MyType" minOccurs="0" maxOccurs="10" />
                <!-- instance with exactly 1 -->
                <xs:element name="useOfTypeB" type="MyType" minOccurs="1" maxOccurs="1" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>