GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — XsdGenerator: emit mixed="true" on complexTypes with xml.format="mixed" fields by gnodet · Pull Request #628 · codehaus-plexus/modello

Conversation

@gnodet

@gnodet gnodet commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

When a Modello field is annotated with xml.format="mixed", the corresponding XML element accepts both free text and child elements. The XSD generator must reflect this with mixed="true" on the xs:complexType.

Two cases are handled:

  1. Field with xml.format="mixed" and xml.tagName (wrapper element): the content lives inside the wrapper child element, so the anonymous xs:complexType written by writeListElement() gets mixed="true".

  2. Field with xml.format="mixed" and no xml.tagName: the content is body text of the class element itself, so the named xs:complexType written by writeComplexTypeDescriptor() gets mixed="true". Fields with xml.tagName are explicitly excluded from this check because their mixed content lives inside a wrapper child element (case 1), not in the class body.

Without this fix, IDEs and XSD validators reject the inline text syntax even though the generated StAX reader accepts it correctly.

Discovered while working on gnodet/maven#139.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet added a commit to gnodet/maven that referenced this pull request Nov 8, 2026
@gnodet
api/maven-api-settings: use Modello 2.8.2-SNAPSHOT for mixed="true" X…
8896ec3
…SD fix

The XSD for <options> and <alias> must carry mixed="true" on their
xs:complexType so that IDEs and schema validators accept both the inline
text syntax and the structured <arg>-child syntax documented for these
fields.

The fix is in codehaus-plexus/modello#628 (XsdGenerator: emit
mixed="true" for xml.format="mixed" fields). Pin to the SNAPSHOT until
that PR is released, then update to 2.8.2.
@gnodet-bot gnodet-bot mentioned this pull request Nov 8, 2026
feat: extend settings.xml with CLI defaults, extensions, aliases and lifecycle phases (v2.1.0) gnodet/maven#139
Open
2 of 3 tasks
@gnodet
gnodet requested review from slachiewicz and slawekjaranowski November 8, 2026 13:49
@gnodet
XsdGenerator: emit mixed="true" on complexTypes with xml.format="mixe…
faff993
…d" fields

When a Modello field is annotated with xml.format="mixed", the
corresponding XML element accepts both free text and child elements.
The XSD generator must reflect this with mixed="true" on the
xs:complexType.

Two cases are handled:

1. Field with xml.format="mixed" and xml.tagName (wrapper element):
   the content lives inside the wrapper child element, so the anonymous
   xs:complexType written by writeListElement() gets mixed="true".

2. Field with xml.format="mixed" and no xml.tagName: the content is
   body text of the class element itself, so the named xs:complexType
   written by writeComplexTypeDescriptor() gets mixed="true". Fields
   with xml.tagName are explicitly excluded from this check because their
   mixed content lives inside a wrapper child element (case 1), not in
   the class body.

Without this fix, IDEs and XSD validators reject the inline text syntax
even though the generated StAX reader accepts it correctly.
@gnodet
gnodet force-pushed the fix/xsd-mixed-content-format branch from 530c211 to faff993 Compare November 8, 2026 23:15
gnodet-bot
gnodet-bot reviewed Nov 8, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The fix is correct — both code paths that emit mixed="true" are logically sound:

  • writeComplexTypeDescriptor: the guard m.getTagName() == null correctly excludes wrapper-element fields (Case 1), limiting mixed="true" to body-level class elements only (Case 2).
  • writeListElement: the anonymous xs:complexType inside a wrapper element correctly gets mixed="true" for xml.format="mixed" fields.

Null-safety is fine: getFormat() and getTagName() can both return null; the check uses "mixed".equals(...) and == null.

Missing test coverage. There is no test verifying the generated XSD. Consider adding a test model in modello-plugins/modello-plugin-xsd/src/test/resources/ with:

  • a field annotated xml.format="mixed" without xml.tagName (body-level / Case 2), and
  • a field annotated xml.format="mixed" with xml.tagName (wrapper / Case 1 — exercises writeListElement)

Then assert that mixed="true" appears on the class-level xs:complexType for the first case, and on the wrapper's inner xs:complexType for the second — and that it does not appear on unrelated xs:complexType elements.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet
Add XSD mixed-content test coverage
b4a3f6a
Add MixedContentXsdGeneratorTest to verify that the XSD generator
emits mixed="true" on the correct xs:complexType elements when a
field uses xml.format="mixed":

- Case 2 (body-level): a String field with xml.format="mixed" and
  no xml.tagName triggers mixed="true" on the class-level named
  xs:complexType (MixedBody).
- Case 1 (wrapper): a List field with xml.format="mixed" and an
  explicit xml.tagName triggers mixed="true" on the anonymous
  xs:complexType inside the wrapper element (MixedWrapper).
- Control: a class with no mixed field (Plain) must NOT get
  mixed="true" on its xs:complexType.
gnodet-bot
gnodet-bot suggested changes Nov 8, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Following up on my earlier review — the missing test coverage is now addressed. Good work adding both cases and a control assertion.

One issue in the new test:

assertNotNull(xsdFile, ...) does not check that the file was actually created. new File(path) never returns null — this assertion is always true whether the XSD was generated or not. A silent generation failure (e.g. wrong output directory) would leave the XSD file absent, doc = db.parse(xsdFile) would throw, and the error message would be "No such file or directory" instead of the intended "Generated XSD file must exist".

Replace with assertTrue(xsdFile.exists(), ...).

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...o-plugin-xsd/src/test/java/org/codehaus/modello/plugin/xsd/MixedContentXsdGeneratorTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

gnodet added 2 commits November 8, 2026 23:40
@gnodet
fix: use xml-apis 1.4.01 to fix JDK 8 test failure
270e19f
xml-apis:2.0.2 is a phantom version that Maven relocates to 1.0.b2,
which does not include org.w3c.dom.ElementTraversal. The class is part
of the JDK since Java 9, so the test passes on JDK 9+, but fails on
JDK 8. The last real release containing ElementTraversal is 1.4.01.
@gnodet
Fix: use assertTrue(xsdFile.exists()) instead of vacuous assertNotNull
a626a5b
gnodet-bot
gnodet-bot reviewed Nov 8, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Previous finding addressed — assertTrue(xsdFile.exists(), ...) is in place. LGTM.

Pre-fix validation: static trace confirms the test was failing before the fix — without w.addAttribute("mixed", "true"), the XPath finds 0 complexType nodes with mixed="true", causing assertEquals(1, 0) to fail on both assertions.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
slachiewicz
slachiewicz approved these changes Nov 9, 2026
View reviewed changes
@gnodet
gnodet merged commit e7dc022 into codehaus-plexus:master Nov 9, 2026
8 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@slachiewicz slachiewicz added the enhancement New feature or request label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slachiewicz slachiewicz slachiewicz approved these changes
@slawekjaranowski slawekjaranowski Awaiting requested review from slawekjaranowski
+1 more reviewer
@gnodet-bot gnodet-bot gnodet-bot requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gnodet @slachiewicz @gnodet-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.