Skip to content

Commit 8c24415

Browse files
committed
xml
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 41b3dc3 commit 8c24415

8 files changed

+114
-8
lines changed

schema/bom-1.6.schema.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@
464464
"versionRange": {
465465
"$ref": "#/definitions/versionRange",
466466
"title": "Component Version Range",
467-
"description": "The component version range that may be provided to fulfill this capability.\nMay only occur if `isExtraneous` is `true`."
467+
"description": "The component version range that may be provided to fulfill this capability.\nMAY only occur if `isExtraneous` is `true`."
468468
},
469469
"description": {
470470
"type": "string",
@@ -621,7 +621,8 @@
621621
{
622622
"$comment": "`version-range` MUST only be present, if `isExtraneous` is `true`",
623623
"if": { "properties": { "isExtraneous": { "const": false } } },
624-
"then": { "not": { "required": ["versionRange"] } }
624+
"then": { "not": { "required": ["versionRange"] } },
625+
"else": true
625626
}
626627
]
627628
},

schema/bom-1.6.xsd

+30-6
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,20 @@ limitations under the License.
500500
of the component. Examples: commons-lang3 and jquery</xs:documentation>
501501
</xs:annotation>
502502
</xs:element>
503-
<xs:element name="version" type="bom:versionType" minOccurs="0" maxOccurs="1">
504-
<xs:annotation>
505-
<xs:documentation>The component version. The version should ideally comply with semantic versioning
506-
but is not enforced.</xs:documentation>
507-
</xs:annotation>
508-
</xs:element>
503+
<xs:choice>
504+
<xs:element name="version" type="bom:versionType" minOccurs="0" maxOccurs="1">
505+
<xs:annotation>
506+
<xs:documentation>The component version. The version should ideally comply with semantic versioning
507+
but is not enforced.</xs:documentation>
508+
</xs:annotation>
509+
</xs:element>
510+
<xs:element name="versionRange" type="bom:versionRangeType" minOccurs="0" maxOccurs="1">
511+
<xs:annotation>
512+
<xs:documentation>The component version range that may be provided to fulfill this capability.
513+
MAY only occur if `isExtraneous` is `true`.</xs:documentation>
514+
</xs:annotation>
515+
</xs:element>
516+
</xs:choice>
509517
<xs:element name="description" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
510518
<xs:annotation>
511519
<xs:documentation>Specifies a description for the component</xs:documentation>
@@ -667,12 +675,28 @@ limitations under the License.
667675
</xs:documentation>
668676
</xs:annotation>
669677
</xs:attribute>
678+
<xs:attribute name="isExtraneous" type="xs:boolean" default="false">
679+
<xs:annotation>
680+
<xs:documentation>
681+
Whether this component is extraneous.
682+
An extraneous component is not part of an assembly, but are (expected to be) provided by the environment, regardless of the component's `scope`.
683+
</xs:documentation>
684+
</xs:annotation>
685+
</xs:attribute>
670686
<xs:anyAttribute namespace="##any" processContents="lax">
671687
<xs:annotation>
672688
<xs:documentation>User-defined attributes may be used on this element as long as they
673689
do not have the same name as an existing attribute used by the schema.</xs:documentation>
674690
</xs:annotation>
675691
</xs:anyAttribute>
692+
<!--
693+
this would be formal, if the support for XSD1.1's `assert` was properly implemented
694+
in validators and tools digesting XML.
695+
<xs:assert id="versionRange_requires_isExtraneous_eq_true"
696+
test="if (versionRange) then (@isExtraneous eq 'true') else true()">
697+
child `versionRange` MAY only be present, if attribute `isExtraneous` is `true`
698+
</xs:assert>
699+
-->
676700
</xs:complexType>
677701

678702
<xs:complexType name="licenseType">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
3+
serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1"
4+
>
5+
<!--
6+
this would be formal, if the support for XSD1.1's `assert` was properly implemented
7+
in validators and tools digesting XML.
8+
-->
9+
<components>
10+
<component type="library" isExtraneous="false">
11+
<name>InvalidVersions</name>
12+
<versionRange><![CDATA[>=9.0.0|<10.0.0]]></versionRange>
13+
<description>versionRange may only exist on extraneous components, set `isExtraneous` explicit</description>
14+
</component>
15+
</components>
16+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
3+
serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1"
4+
>
5+
<!--
6+
this would be formal, if the support for XSD1.1's `assert` was properly implemented
7+
in validators and tools digesting XML.
8+
-->
9+
<components>
10+
<component type="library">
11+
<!-- @isExtraneous defaults to `false` -->
12+
<name>InvalidVersions</name>
13+
<versionRange><![CDATA[>=9.0.0|<10.0.0]]></versionRange>
14+
<description>versionRange may only exist on extraneous components, set `isExtraneous` implicit by default value</description>
15+
</component>
16+
</components>
17+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
3+
serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1"
4+
>
5+
<components>
6+
<component type="library" isExtraneous="false">
7+
<name>InvalidVersions</name>
8+
<version>9.0.14</version>
9+
<versionRange><![CDATA[>=9.0.0|<10.0.0]]></versionRange>
10+
<description>may have `version` or `versionRange`, not both. This one does - it is invalid</description>
11+
</component>
12+
</components>
13+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
3+
serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1"
4+
>
5+
<components>
6+
<component type="library" isExtraneous="true">
7+
<name>Foo</name>
8+
<description>extraneous without any version constraints</description>
9+
</component>
10+
</components>
11+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
3+
serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1"
4+
>
5+
<components>
6+
<component type="library" isExtraneous="true">
7+
<name>Foo</name>
8+
<version>9.1.24</version>
9+
<description>extraneous with version constraint</description>
10+
</component>
11+
</components>
12+
</bom>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<bom xmlns="http://cyclonedx.org/schema/bom/1.6"
3+
serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1"
4+
>
5+
<components>
6+
<component type="library" isExtraneous="true">
7+
<name>Foo</name>
8+
<versionRange><![CDATA[>=9.0.0|<10.0.0]]></versionRange>
9+
<description>extraneous with version range constraints</description>
10+
</component>
11+
</components>
12+
</bom>

0 commit comments

Comments
 (0)