Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Details
Adds support for optional elements where
minOccurs=0
.Description
At present, elements have an
Optional
field that is never set during XSD parsing. This PR sets the field and adds support for it to the Go generator. The Rust generator already has it implemented.Credit goes to geoko86 for the fix. I cherry-picked the commit from this PR: geoko86#1
Related Issue
#47
Motivation and Context
XSD provides a way to express a tag that can be omitted without breaking the spec. That freedom does not make it into the generated code as it tends to always include tags whether or not they have been initialized.
How Has This Been Tested
I tested this code on a Linux system using the existing test cases in this repository. The
TopLevel
element includes an optional element withminOccurs="0" maxOccurs="1"
. The test's expected values however don't respect theminOccurs
. The tests broke after making this change and worked again after changing the Go and Rust expected results to use their respective representations for optional elements.I have also tested the Go code generated from a proprietary schema and verified that, after serializing the generated models, empty tags are no longer included.
Types of changes
Checklist