Skip to content

Commit 633b4cc

Browse files
committed
intro to explicitely linked elements
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 36ac6cd commit 633b4cc

File tree

3 files changed

+56
-11
lines changed

3 files changed

+56
-11
lines changed

schema/bom-1.5.xsd

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,21 @@ limitations under the License.
3737

3838
<xs:simpleType name="refType">
3939
<xs:annotation>
40-
<xs:documentation>Identifier-DataType for interlinked elements.</xs:documentation>
40+
<xs:documentation>Identifier-DataType for interlink-able elements.</xs:documentation>
4141
</xs:annotation>
42-
<xs:restriction base="xs:string" />
42+
<xs:restriction base="xs:string">
43+
<xs:minLength value="1"/>
44+
<!-- value SHOULD not start with the BOM-Link intro "urn:cdx:" -->
45+
</xs:restriction>
46+
</xs:simpleType>
47+
<xs:simpleType name="refLinkType">
48+
<xs:annotation>
49+
<xs:documentation xml:lang="en">
50+
Descriptor for an element identified by the attribute "bom-ref" in the same BOM document.
51+
In contrast to `bomLinkElementType`.
52+
</xs:documentation>
53+
</xs:annotation>
54+
<xs:restriction base="bom:refType"/>
4355
</xs:simpleType>
4456

4557
<xs:simpleType name="bomLinkDocumentType">
@@ -1339,7 +1351,7 @@ limitations under the License.
13391351

13401352
<xs:complexType name="externalReference">
13411353
<xs:sequence>
1342-
<xs:element name="url" type="xs:anyURI" minOccurs="1" maxOccurs="1">
1354+
<xs:element name="url" minOccurs="1" maxOccurs="1">
13431355
<xs:annotation>
13441356
<xs:documentation xml:lang="en">The URI (URL or URN) to the external reference. External references
13451357
are URIs and therefore can accept any URL scheme including https, mailto, tel, and dns.
@@ -1348,6 +1360,9 @@ limitations under the License.
13481360
references into relationships that can be expressed in a BOM or across BOMs. Refer to:
13491361
https://cyclonedx.org/capabilities/bomlink/</xs:documentation>
13501362
</xs:annotation>
1363+
<xs:simpleType>
1364+
<xs:union memberTypes="xs:anyURI bom:bomLinkType"/>
1365+
</xs:simpleType>
13511366
</xs:element>
13521367
<xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="1">
13531368
<xs:annotation>
@@ -1728,7 +1743,7 @@ limitations under the License.
17281743
<xs:sequence minOccurs="0" maxOccurs="unbounded">
17291744
<xs:element name="dependency" type="bom:dependencyType"/>
17301745
</xs:sequence>
1731-
<xs:attribute name="ref" type="bom:refType" use="required">
1746+
<xs:attribute name="ref" type="bom:refLinkType" use="required">
17321747
<xs:annotation>
17331748
<xs:documentation>References a component or service by the its bom-ref attribute</xs:documentation>
17341749
</xs:annotation>
@@ -1861,7 +1876,11 @@ limitations under the License.
18611876
</xs:annotation>
18621877
<xs:complexType>
18631878
<xs:sequence minOccurs="0" maxOccurs="unbounded">
1864-
<xs:element name="url" type="xs:anyURI"/>
1879+
<xs:element name="url">
1880+
<xs:simpleType>
1881+
<xs:union memberTypes="xs:anyURI bom:bomLinkElementType"/>
1882+
</xs:simpleType>
1883+
</xs:element>
18651884
</xs:sequence>
18661885
</xs:complexType>
18671886
</xs:element>
@@ -1871,7 +1890,11 @@ limitations under the License.
18711890
</xs:annotation>
18721891
<xs:complexType>
18731892
<xs:sequence minOccurs="0" maxOccurs="unbounded">
1874-
<xs:element name="url" type="xs:anyURI"/>
1893+
<xs:element name="url">
1894+
<xs:simpleType>
1895+
<xs:union memberTypes="xs:anyURI bom:bomLinkElementType"/>
1896+
</xs:simpleType>
1897+
</xs:element>
18751898
</xs:sequence>
18761899
</xs:complexType>
18771900
</xs:element>
@@ -2606,10 +2629,13 @@ limitations under the License.
26062629
</xs:annotation>
26072630
<xs:complexType>
26082631
<xs:choice minOccurs="0" maxOccurs="unbounded">
2609-
<xs:element name="ref" type="bom:refType" minOccurs="0" maxOccurs="1">
2632+
<xs:element name="ref" minOccurs="0" maxOccurs="1">
26102633
<xs:annotation>
26112634
<xs:documentation>References a data component by the components bom-ref attribute</xs:documentation>
26122635
</xs:annotation>
2636+
<xs:simpleType>
2637+
<xs:union memberTypes="bom:refLinkType bom:bomLinkElementType"/>
2638+
</xs:simpleType>
26132639
</xs:element>
26142640
<xs:element name="dataset" type="bom:componentDataType" minOccurs="0" maxOccurs="1" />
26152641
</xs:choice>
@@ -3171,10 +3197,13 @@ limitations under the License.
31713197
</xs:simpleType>
31723198

31733199
<xs:complexType name="bomReferenceType">
3174-
<xs:attribute name="ref" type="bom:refType" use="required">
3200+
<xs:attribute name="ref" use="required">
31753201
<xs:annotation>
31763202
<xs:documentation>References a component or service by the its bom-ref attribute</xs:documentation>
31773203
</xs:annotation>
3204+
<xs:simpleType>
3205+
<xs:union memberTypes="bom:refLinkType bom:bomLinkType"/>
3206+
</xs:simpleType>
31783207
</xs:attribute>
31793208
<xs:anyAttribute namespace="##other" processContents="lax">
31803209
<xs:annotation>
@@ -3528,10 +3557,13 @@ limitations under the License.
35283557
<xs:element name="target">
35293558
<xs:complexType>
35303559
<xs:sequence minOccurs="0" maxOccurs="1">
3531-
<xs:element name="ref" type="bom:refType" minOccurs="1" maxOccurs="1">
3560+
<xs:element name="ref" minOccurs="1" maxOccurs="1">
35323561
<xs:annotation>
35333562
<xs:documentation>References a component or service by the objects bom-ref.</xs:documentation>
35343563
</xs:annotation>
3564+
<xs:simpleType>
3565+
<xs:union memberTypes="bom:refLinkType bom:bomLinkElementType"/>
3566+
</xs:simpleType>
35353567
</xs:element>
35363568
<xs:element name="versions" minOccurs="0" maxOccurs="1">
35373569
<xs:annotation>

tools/src/test/resources/1.5/invalid-component-ref-1.5.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
<version>1.0.0</version>
77
<components>
88
<component type="library" bom-ref="123">
9+
<!-- duplicate value in attribute `bom-ref` -->
10+
<name>acme-library</name>
11+
<version>1.0.0</version>
12+
</component>
13+
<component type="library" bom-ref="">
14+
<!-- empty value in attribute `bom-ref` -->
915
<name>acme-library</name>
1016
<version>1.0.0</version>
1117
</component>

tools/src/test/resources/1.5/invalid-dependency-1.5.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
</component>
1616
</components>
1717
<dependencies>
18-
<dependency />
18+
<dependency>
19+
<!-- invalid: missing attribute `ref` -->
20+
</dependency>
21+
<dependency ref="">
22+
<!-- invalid: attribute `ref` is empty -->
23+
</dependency>
1924
<dependency ref="library-b">
20-
<dependency ref="library-c"/>
25+
<dependency ref="library-c">
26+
<!-- valid -->
27+
</dependency>
2128
</dependency>
2229
</dependencies>
2330
</bom>

0 commit comments

Comments
 (0)