Allow arbitrary attributes on DOM elements in generated XSD - #574
Merged
Conversation
A DOM field maps to an element that carries free-form XML, so merge hints such as combine.self and combine.children may appear on it. The generated schema declared no attributes there, which made a POM using them fail validation. Emit <xs:anyAttribute processContents="skip"/> for DOM fields only. Properties fields share the same writer but their container element never carries attributes, so they keep the stricter schema. Fixes #482 Co-authored-by: XenoAmess <xenoamess@gmail.com>
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.
Reworked version of #483, which fixes #482.
A
DOMfield maps to an element carrying free-form XML, so DOM merge hints may appear on it:The generated
xs:complexTypedeclared no attributes, so this failed schema validation even though Maven accepts it. Nested elements were already covered by the existingxs:any processContents="skip"; only the element itself was missing an attribute wildcard.Changes
XsdGeneratoremits<xs:anyAttribute processContents="skip"/>forDOMfields.writePropertiesElementis shared byDOMandjava.util.Propertiesfields, so it now takes a flag. APropertiescontainer element never carries attributes, so it keeps the stricter schema and typos there are still reported.DomXsdGeneratorTest, followingFeaturesXsdGeneratorTest: it generates the schema, validates a document usingcombine.selfon the DOM element, and asserts that the same attribute on aPropertieselement is still rejected. The test fails without the generator change.Differences from #483
master— that PR predates the test migration in chore: migrate junit 3 test to junit4 #523 and no longer compiles (lookup(ModelloCore.ROLE), no@Test/@PlexusTest).DOM; add <xs:anyAttribute processContents="skip"/> to DOM type's complexType generated (in xsd generation) #483 also loosenedProperties.maven.mdois replaced by a 42-linedom.mdo, and the test gets its own output directory instead of sharingtarget/generator-results/xsdwithXsdGeneratorTest.Credit to @XenoAmess for the diagnosis and the original patch.