Repository navigation
Support xs:enumeration restrictions in XSD generation via field metadata - #634
Merged
gnodet merged 2 commits intoNov 10, 2026
Merged
Conversation
Add three new field-level XSD metadata attributes: - xsd.enumerations: strict restriction — rejects unknown values - xsd.suggestions: non-strict union — IDE autocompletion without rejection - xsd.pattern: pattern restriction via xs:pattern facet Changes: - XsdFieldMetadata: add enumerations, suggestions, pattern fields - XsdMetadataPlugin: parse xsd.enumerations, xsd.suggestions, xsd.pattern from the field data map (comma-separated for enum/suggestion lists) - XsdGenerator: emit inline xs:simpleType with xs:restriction/xs:enumeration, xs:union, or xs:pattern when the metadata is present; plain xs:string type attribute is used only when no constraint is defined - EnumerationXsdGeneratorTest + fixtures: cover all three modes plus the non-strict round-trip (custom packaging value must pass validation) Fixes codehaus-plexus#633
gnodet-bot
reviewed
Nov 9, 2026
gnodet-bot
left a comment
There was a problem hiding this comment.
The PR adds xsd.enumerations, xsd.suggestions, and xsd.pattern field metadata to the Modello XSD generator — a genuinely useful feature with thorough Javadoc and XSD validation tests. A few things to address before this is ready:
This review was generated by an AI agent, Hermès on behalf of @gnodet.
…attribute field test
gnodet-bot
approved these changes
Nov 10, 2026
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all 4 findings have been addressed:
- ✅
getEnumerations()/getSuggestions()— now returnCollections.unmodifiableList(...), preventing external mutation. - ✅ Mutual-exclusivity validation —
getFieldMetadata()now throwsModelloExceptionwhen more than one ofxsd.enumerations,xsd.suggestions, orxsd.patternis set on the same field. - ✅
xml.attribute="true"test coverage —attributeScopefield added to the.mdofixture with enumeration constraint; assertion 5 intestEnumerationConstraintsverifies the attribute-field code path.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #633
Summary
Adds three new field-level XSD metadata attributes to
modello-plugin-xsd:xsd.enumerationsxs:restrictionwithxs:enumerationxsd.suggestionsxs:unionof enumeration +xs:stringxsd.patternxs:restrictionwithxs:patternUsage
Generated XSD (strict enumeration example)
Changes
XsdFieldMetadata: addenumerations,suggestions,patternfieldsXsdMetadataPlugin: parsexsd.enumerations,xsd.suggestions,xsd.patternfrom the field data mapXsdGenerator: emit inlinexs:simpleTypewhen any constraint is present; plaintype="xs:string"used only for unconstrained fields; also supports constrainedxs:attributefieldsEnumerationXsdGeneratorTest+ fixtures: cover all three modes, verify structural XSD content via XPath, validate that good XML passes and bad values/patterns are rejected, and confirm that custom values outsidexsd.suggestionsstill pass validation