Open-CMSIS-Pack / Open-CMSIS-Pack-Spec

Common Microcontroller Software Interface Standard - Pack(age) based distribution system
https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/
Apache License 2.0
54 stars 22 forks source link

Add `environment` element at `board` and `component` level #234

Closed silviooliva closed 1 year ago

silviooliva commented 1 year ago

Commit related to issue #230.

silviooliva commented 1 year ago

I've introduced the <environment> element as child element of the <board> and the <component>.

Just a quick explanation hereafter concerning the modification to the <component> in the PACK.xsd schema.

The <component> element is defined as a <xs:complexType> and all its child elements are contained into the <xs:all> schema component. Now, since the child elements in the <xs:all> can have only maxOccur=1, I cannot define the <environment> directly into the <component> in this simple way (that is with maxOccurs="unbounded):

<xs:element name="component" minOccurs="0" maxOccurs="unbounded">
  <xs:complexType>
    <xs:all>
      ... ... ... 

<xs:element name="environment" type="EnvironmentType" minOccurs="0" maxOccurs="unbounded" />

      ... ... ... 
    </xs:all>
    <!-- component identity attributes -->
    <xs:attribute name="Cvendor" type="CvendorType" use="optional" />
    ... ... ...
  </xs:complexType>
</xs:element>

To overcome this issue, I had to define an <environments> element to be used as container of the possible <environment> elements. Here a snapshot of the xsd code:

<xs:element name="component" minOccurs="0" maxOccurs="unbounded">
  <xs:complexType>
    <xs:all>
      ... ... ...

<!-- list of environments (elements containing information that is specific for a development tool) --> <xs:element name="environments" minOccurs="0" > <xs:complexType> <xs:sequence> <xs:element name="environment" type="EnvironmentType" minOccurs="1" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element>

      ... ... ... 
    </xs:all>
    <!-- component identity attributes -->
    <xs:attribute name="Cvendor" type="CvendorType" use="optional" />
    ... ... ...
  </xs:complexType>
</xs:element>

This solution, thanks to the <environments> container and without changing the in the component xsd definition, allows a pack developer to declare unlimited <environment> elements.