# cvc-complex-type.2.4.b: The content of element is not complete

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

> An element ended before all the children the schema requires appeared.

The message, as Java reports it: `cvc-complex-type.2.4.b: The content of element 'order' is not complete. One of '{qty}' is expected.`

## Why it happens

- A required child element is missing: its `minOccurs` is 1 (the default) and the document leaves it out.
- The child is there but in another namespace, so Xerces does not count it.
- An empty element (`<order/>`) where the schema expects content.

## How to fix it

- The message names the element that is incomplete and, in braces, what it still needs. Add the missing child at the end of that element, or make it optional in the schema (`minOccurs="0"`) if it really is. When generating XML with JAXB, a `null` field is left out, so a required element with no value triggers this error.
- 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 [Missing child element(s)](https://xmlvalid.com/errors/missing-child-elements): `Element 'order': Missing child element(s). Expected is ( qty ).`

## Example that fails

```xml
<order currency="EUR">
  <id>A-1</id>
</order>
```

## Fixed

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