# cvc-complex-type.2.4.d: No child element is expected at this point

Source: https://xmlvalid.com/errors/cvc-complex-type-2-4-d

> An element appears after the parent's content is already complete: the schema allows nothing more there.

The message, as Java reports it: `cvc-complex-type.2.4.d: Invalid content was found starting with element 'extra'. No child element is expected at this point.`

## Why it happens

- An element the schema doesn't know at all, added at the end of its parent.
- One occurrence too many of the last element (`maxOccurs` reached).
- An element that belongs earlier in the sequence, placed after the last one.

## How to fix it

- Remove the element, or move it where the schema allows it; if it should be allowed, add it to the parent's type in the schema. Unlike *2.4.a*, Xerces lists nothing because nothing at all is accepted at that point.
- Java's schema validation (`javax.xml.validation.Validator`, and JAXB or Spring on top of it) throws at the first error unless you set an `ErrorHandler` whose `error()` records the `SAXParseException` and carries on; each one has `getLineNumber()` and `getColumnNumber()`. A well-formedness error ends parsing whatever the handler does.

## The same problem in xmlvalid

libxml2, which xmlvalid validates with, reports it as [This element is not expected](https://xmlvalid.com/errors/this-element-is-not-expected): `Element 'qty': This element is not expected. Expected is ( id ).`

## Example that fails

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>2</qty>
  <note>gift</note>
  <extra/>
</order>
```

## Fixed

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>2</qty>
  <note>gift</note>
</order>
```
