Skip to content

Write standard levels as level elements in XML - #985

Open
wleeaf wants to merge 1 commit into
CycloneDX:masterfrom
wleeaf:standard-levels-xml
Open

wleeaf wants to merge 1 commit into
CycloneDX:masterfrom
wleeaf:standard-levels-xml

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 25, 2026

Copy link
Copy Markdown

Standard.getLevels() has no XML wrapper annotations, so the XML generator writes each level as a <levels> element inside the <levels> wrapper:

<levels>
  <levels bom-ref="level-1">
    <identifier>Level 1</identifier>
    ...

The 1.6 and 1.7 XSDs expect <levels><level>, so validation of the output fails with cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://cyclonedx.org/schema/bom/1.6":levels}'. One of '{"http://cyclonedx.org/schema/bom/1.6":level}' is expected. This happens when valid-standard-1.6.xml or valid-standard-1.6.json (and the 1.7 files) is parsed and XML is generated again.

This annotates getLevels() with @JacksonXmlElementWrapper(localName = "levels") and @JacksonXmlProperty(localName = "level"), the same way getRequirements() and Level.getRequirements() already are. JSON output is unchanged.

schema16StandardLevelsGenerationTest generates XML from /1.6/valid-standard-1.6.xml and checks that it has <level bom-ref="level-1"> and passes the XSD. It fails without the change and passes with it. mvn -B test passes: 1762 tests, 0 failures.

Standard.getLevels had no XML wrapper annotations, so the XML generator
wrote each level as a <levels> element inside <levels>. The XSD expects
<levels><level>, so re-generating the spec test file
valid-standard-1.6.xml (or the JSON one) gave an invalid BOM.

Annotate it like getRequirements and Level.getRequirements.

Signed-off-by: Wleeaf <179125857+wleeaf@users.noreply.github.com>
@wleeaf
wleeaf requested a review from a team as a code owner October 25, 2026 10:46
Copilot AI balanced review requested due to automatic review settings October 25, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@codacy-production

codacy-production Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (849e474) 7435 5528 74.35%
Head commit (f8ed6f3) 7435 (+0) 5528 (+0) 74.35% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#985) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants