diff --git a/cyclonedx/exception/output.py b/cyclonedx/exception/output.py index 76ed11e2..58e83976 100644 --- a/cyclonedx/exception/output.py +++ b/cyclonedx/exception/output.py @@ -22,14 +22,6 @@ from . import CycloneDxException -class ComponentVersionRequiredException(CycloneDxException): - """ - Exception raised when attempting to output to an SBOM version that mandates a Component has a version, - but one is not available/present. - """ - pass - - class FormatNotSupportedException(CycloneDxException): """ Exception raised when attempting to output a BOM to a format not supported in the requested version. diff --git a/cyclonedx/output/xml.py b/cyclonedx/output/xml.py index 79516850..77338e43 100644 --- a/cyclonedx/output/xml.py +++ b/cyclonedx/output/xml.py @@ -24,7 +24,6 @@ from . import BaseOutput, SchemaVersion from .schema import BaseSchemaVersion, SchemaVersion1Dot0, SchemaVersion1Dot1, SchemaVersion1Dot2, SchemaVersion1Dot3, \ SchemaVersion1Dot4 -from ..exception.output import ComponentVersionRequiredException from ..model import ExternalReference, HashType, OrganizationalEntity, OrganizationalContact, Tool from ..model.bom import Bom from ..model.component import Component @@ -147,11 +146,9 @@ def _add_component_element(self, component: Component) -> ElementTree.Element: ElementTree.SubElement(component_element, 'version').text = component.version else: if not component.version: - raise ComponentVersionRequiredException( - f'Component "{str(component)}" has no version but the target schema version mandates ' - f'Components have a version specified' - ) - ElementTree.SubElement(component_element, 'version').text = component.version + ElementTree.SubElement(component_element, 'version') + else: + ElementTree.SubElement(component_element, 'version').text = component.version # hashes if component.hashes: