The parent has already consumed all the children its content model permits, yet another element arrives. Xerces reports that no child is expected at this point. This is a structural overflow rather than a failure to parse the tag.
What the message literally means
The schema permits exactly one line inside batch. The second line exceeds maxOccurs="1", so removing the accidental duplicate yields a complete valid batch. The corrected toy document illustrates duplicate removal; real application data must be reconciled before any record is discarded.
Three common causes to check first
A child exceeds its maximum count. Remember that maxOccurs defaults to one when the attribute is absent.
Two mutually exclusive choice branches were emitted together. Once the permitted branch is complete, the next branch may be an additional illegal child.
A field was written at the wrong nesting level. A tag intended for the next record can arrive after the current parent’s allowed content has finished.
Repair and retest
Inspect the parent’s particle and the occurrence limits of both the child and enclosing groups. Count children in document order, then identify the transition after which the validator expects the parent to end. Correct the export loop, duplicate join or container boundary that produced the surplus. Rerun with a real multi-record example to check that the repair preserves every intended record.
When this is a namespace problem
Changing a namespace cannot make a truly exhausted content model accept more children. A namespace mismatch may influence which earlier branch was selected, so inspect earlier diagnostics first. If a repeated child has the same expanded name as its accepted predecessor, occurrence counting is the stronger lead.
System.Xml.Schema: invalid child after completed content
The a and d suffixes answer different questions. The a case can often name another expected child; the d case says the parent should stop accepting children. Increasing maxOccurs without agreement changes the contract and can conceal accidental duplication in upstream data.
Complete tested XML and XSD pairs
Open either variant in the workbench, then choose Validate XML. Loading an example does not run validation or send documents; server checks require the existing permission checkbox.
cvc-complex-type.2.4.d: Invalid content was found starting with element 'line'. No child element is expected at this point.
PASS
.NET 8.0.33 · System.Xml.Schema Validation
The element 'batch' has invalid child element 'line'.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2 Validation
Element 'line': This element is not expected.
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0 Validation
Unexpected child with tag 'line' at position 2.
PASS
Saxon
EE comparison: cvc-complex-type.2.4.d describes the corresponding XSD constraint. No Saxon-EE run or wording is claimed; an EE licence is unavailable in this test environment. Saxon-HE does not provide XSD validation.
The corrected results apply to these self-contained XSD 1.0 specimens. They do not establish business-rule acceptance for a different document or schema version.