Skip to content

Skip None text when binding wildcard list elements - #1237

Merged
tefra merged 1 commit into
mainfrom
fix-mixed-content-none-text
Oct 16, 2026
Merged

tefra merged 1 commit into
mainfrom
fix-mixed-content-none-text

Conversation

@tefra

@tefra tefra commented Oct 16, 2026

Copy link
Copy Markdown
Owner

📒 Description

Mixed content and other list wildcards got a stray None at the start of the list when the element had no text (or only whitespace) before its first child but did have a tail.

Resolves #1130

🔗 What I've Done

ElementNode.bind_wild_text normalizes the text first. The early return only covered the case where both text and tail were None, so the list branch inserted None whenever the tail alone was set. The list branch never uses the tail, because the parent node already appends it. The list branch now returns early when the text is None.

Example from the voko abak.xml sample, <fnt>\n <bib>RugxDom</bib> ...:

# before
Fnt(content=[None, Bib(value='RugxDom'), Lok(...)])
# after
Fnt(content=[Bib(value='RugxDom'), Lok(...)])

💬 Comments

Serialized XML doesn't change, because the serializer already skipped None entries. Only code that reads the parsed content lists sees the difference.

🛫 Checklist

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (cd7a341) to head (fb06435).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1237   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files         117      117           
  Lines        9412     9414    +2     
  Branches     1446     1447    +1     
=======================================
+ Hits         9410     9412    +2     
  Misses          1        1           
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tefra
tefra merged commit 5160f48 into main Oct 16, 2026
13 of 14 checks passed
@tefra
tefra deleted the fix-mixed-content-none-text branch October 16, 2026 08:36
tefra added a commit to tefra/xsdata-w3c-tests that referenced this pull request Oct 16, 2026
Skip None text in wildcard list elements (tefra/xsdata#1237) and pick up the w3c test data changes from 7bc3365.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't pass DTD resolvers to LxmlEventHandler

1 participant