Skip to content

Allow arbitrary attributes on DOM elements in generated XSD - #574

Merged
slachiewicz merged 1 commit into
masterfrom
xsd-dom-anyattribute
Aug 8, 2026
Merged

Allow arbitrary attributes on DOM elements in generated XSD#574
slachiewicz merged 1 commit into
masterfrom
xsd-dom-anyattribute

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Reworked version of #483, which fixes #482.

A DOM field maps to an element carrying free-form XML, so DOM merge hints may appear on it:

<configuration combine.self="override">
  <goalPrefix combine.self="override"/>
</configuration>

The generated xs:complexType declared no attributes, so this failed schema validation even though Maven accepts it. Nested elements were already covered by the existing xs:any processContents="skip"; only the element itself was missing an attribute wildcard.

Changes

  • XsdGenerator emits <xs:anyAttribute processContents="skip"/> for DOM fields.
  • writePropertiesElement is shared by DOM and java.util.Properties fields, so it now takes a flag. A Properties container element never carries attributes, so it keeps the stricter schema and typos there are still reported.
  • New DomXsdGeneratorTest, following FeaturesXsdGeneratorTest: it generates the schema, validates a document using combine.self on the DOM element, and asserts that the same attribute on a Properties element is still rejected. The test fails without the generator change.

Differences from #483

Credit to @XenoAmess for the diagnosis and the original patch.

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>
@slachiewicz slachiewicz added the enhancement New feature or improvement label Aug 8, 2026
@slachiewicz
slachiewicz merged commit 8554215 into master Aug 8, 2026
12 checks passed
@slachiewicz
slachiewicz deleted the xsd-dom-anyattribute branch August 8, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

need ways to generate both xs:sequence and xs:attribute into a same xs:complexType, for maven

1 participant