# s4s-elt-* errors: the XSD itself has invalid structure

The s4s family refers to schema-for-schemas checks: the validator is reading an XSD document whose own vocabulary or child arrangement is invalid. These failures occur before ordinary instance validation, even when the XML document is entirely reasonable.

## Literal meaning

Three tested subcodes illustrate the family. s4s-elt-invalid-content.1 rejects the misspelled top-level complexTyp. s4s-elt-must-match.1 rejects an xs:element nested directly inside another xs:element. s4s-elt-must-match.2 reports an empty xs:simpleType that lacks restriction, list or union. The exact suffix depends on context; a typo does not always produce the same code.

## Three common causes

1. A schema keyword is misspelled, has incorrect case or uses the wrong namespace. complexTyp is not an XSD declaration, even though the document remains well-formed XML.
2. A valid schema construct appears under the wrong parent or in the wrong order. Declaring a child element requires a suitable complex type and content model around it.
3. A required schema child is omitted, or an XSD-version-specific construct reaches a processor that does not support it. Empty scaffolding is not always a legal completed type definition.

## Repair

Use the reported schema location rather than searching the instance XML. Match the named schema parent against its allowed vocabulary, then fix spelling, nesting or missing required content. Compile again after each structural repair so later diagnostics are not interpreted through an already invalid grammar. The corrected samples add the proper complexType/sequence wrapper or a string restriction instead of altering their instance data.

## Namespace checks

All xs-prefixed constructs must resolve to http://www.w3.org/2001/XMLSchema, exactly. Changing the instance document’s default namespace cannot repair an XSD keyword. Conversely, writing schema-looking elements in an application namespace does not define schema components. Check the namespace binding in the XSD file itself when the vocabulary looks correct.

Do not turn this family into one thin page per possible suffix. These examples preserve three genuinely measured diagnostics and show different repairs. Other members such as s4s-elt-schema-ns or s4s-elt-character indicate related schema-authoring conditions, but this guide does not claim to have reproduced those additional subcodes.

## Schema vocabulary / s4s-elt-invalid-content.1 — Broken

```xml
<item/>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item"/>
  <xs:complexTyp name="Empty"/>
</xs:schema>
```

[Open broken pair](https://xsdhub.com/?example=parser-s4s-invalid&variant=bad#workbench)

## Schema vocabulary / s4s-elt-invalid-content.1 — Corrected

```xml
<item/>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item"/>
  <xs:complexType name="Empty"/>
</xs:schema>
```

[Open corrected pair](https://xsdhub.com/?example=parser-s4s-invalid&variant=good#workbench)

### Apache Xerces-J 2.12.2

```text
s4s-elt-invalid-content.1: The content of 'schema' is invalid. Element 'complexTyp' is invalid, misplaced, or occurs too often.
```

Corrected: PASS.

### .NET 8.0.33 · System.Xml.Schema

```text
The 'http://www.w3.org/2001/XMLSchema:complexTyp' element is not supported in this context.
```

Corrected: PASS.

### XSDHub libxml2/WASM 0.7.2

```text
Element '{http://www.w3.org/2001/XMLSchema}schema': The content is not valid. Expected is ((include | import | redefine | annotation)*, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*).
```

Corrected: PASS.

### XSDHub xmlschema 4.3.1 · XSD 1.0

```text
Unexpected child with tag 'xs:complexTyp' at position 2:

Schema component:

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="item" />
    <xs:complexTyp name="Empty" />
  </xs:schema>

Path: /xs:schema

Schema URL: schema.xsd

```

Corrected: PASS.

## Schema content / s4s-elt-must-match.1 — Broken

```xml
<item>
  <child>ok</child>
</item>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:element name="child" type="xs:string"/>
  </xs:element>
</xs:schema>
```

[Open broken pair](https://xsdhub.com/?example=parser-s4s-content&variant=bad#workbench)

## Schema content / s4s-elt-must-match.1 — Corrected

```xml
<item>
  <child>ok</child>
</item>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="child" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

[Open corrected pair](https://xsdhub.com/?example=parser-s4s-content&variant=good#workbench)

### Apache Xerces-J 2.12.2

```text
s4s-elt-must-match.1: The content of 'item' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: element.
```

Corrected: PASS.

### .NET 8.0.33 · System.Xml.Schema

```text
The 'http://www.w3.org/2001/XMLSchema:element' element is not supported in this context.
```

Corrected: PASS.

### XSDHub libxml2/WASM 0.7.2

```text
Element '{http://www.w3.org/2001/XMLSchema}element': The content is not valid. Expected is (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)).
```

Corrected: PASS.

### XSDHub xmlschema 4.3.1 · XSD 1.0

```text
Unexpected child with tag 'xs:element' at position 1:

Schema component:

  <xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="item">
    <xs:element name="child" type="xs:string" />
  </xs:element>

Path: /xs:schema/xs:element

Schema URL: schema.xsd

```

Corrected: PASS.

## Empty simple type / s4s-elt-must-match.2 — Broken

```xml
<item>ok</item>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:simpleType/>
  </xs:element>
</xs:schema>
```

[Open broken pair](https://xsdhub.com/?example=parser-s4s-empty&variant=bad#workbench)

## Empty simple type / s4s-elt-must-match.2 — Corrected

```xml
<item>ok</item>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:simpleType>
      <xs:restriction base="xs:string"/>
    </xs:simpleType>
  </xs:element>
</xs:schema>
```

[Open corrected pair](https://xsdhub.com/?example=parser-s4s-empty&variant=good#workbench)

### Apache Xerces-J 2.12.2

```text
s4s-elt-must-match.2: The content of 'simpleType' must match (annotation?, (restriction | list | union)). Not enough elements were found.
```

Corrected: PASS.

### .NET 8.0.33 · System.Xml.Schema

```text
SimpleType content is missing.
```

Corrected: PASS.

### XSDHub libxml2/WASM 0.7.2

```text
Element '{http://www.w3.org/2001/XMLSchema}simpleType': The content is not valid. Expected is (annotation?, (restriction | list | union)).
```

Corrected: PASS.

### XSDHub xmlschema 4.3.1 · XSD 1.0

```text
The content of element 'xs:simpleType' is not complete. Tag ('xs:restriction' | 'xs:list' | 'xs:union') expected:

Schema component:

  <xs:simpleType xmlns:xs="http://www.w3.org/2001/XMLSchema" />

Path: /xs:schema/xs:element/xs:simpleType

Schema URL: schema.xsd

```

Corrected: PASS.

Saxon EE was not available; no measured Saxon wording is claimed.

[All parser codes](https://xsdhub.com/learn#parser-error-codes)
[Download engine evidence](https://xsdhub.com/parser-error-examples/engine-evidence.json)
