# cvc-elt.1.a: cannot find the declaration of the root

The validator cannot associate the document element with a global element declaration in the supplied schema set. It has not yet reached the question of whether that element’s children are correct. Check the root and the selected schema before editing descendants.

## Literal meaning

In this pair the XSD declares stock in urn:example:stock. The failing XML has an unqualified stock, which belongs to no namespace. Adding the intended default namespace changes stock and its unprefixed sku child into the expanded names expected by the qualified schema.

## Three common causes

1. The root namespace URI differs from targetNamespace, or the XML omits the required namespace entirely. Namespace names are exact identifiers, including case and trailing punctuation.
2. The wrong schema entry point was selected. A file containing only reusable types may have no global declaration for the application’s document root.
3. The root name or vocabulary version changed. A similar-looking declaration from a different release does not establish compatibility with the incoming document.

## Repair

Write down the root as {namespace URI}local-name and compare it with a top-level xs:element in the loaded entry schema. Confirm that the application explicitly supplies that schema. For multi-file contracts, load the full project and select its actual root XSD. Recheck qualification of descendants after correcting the root, since elementFormDefault can expose additional mismatches.

## Namespace checks

This specimen is a namespace error: the only XML change adds xmlns="urn:example:stock". Declaring xmlns:xsi or adding a schemaLocation hint alone would not put stock in that namespace. Conversely, changing only the prefix while retaining the correct binding leaves the expanded name unchanged.

With ReportValidationWarnings enabled, the tested .NET reader returned warnings for stock and sku, with no error event. Treat that as missing schema coverage, not proof of validity. Xerces, libxml2 and XSDHub’s second engine reject this same root. The strict-wildcard guide covers a different .NET message: “is not declared”.

## Undeclared root / cvc-elt.1.a — Broken

```xml
<stock>
  <sku>BK-204</sku>
</stock>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:example:stock" elementFormDefault="qualified">
  <xs:element name="stock">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="sku" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

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

## Undeclared root / cvc-elt.1.a — Corrected

```xml
<stock xmlns="urn:example:stock">
  <sku>BK-204</sku>
</stock>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:example:stock" elementFormDefault="qualified">
  <xs:element name="stock">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="sku" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

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

### Apache Xerces-J 2.12.2

```text
cvc-elt.1.a: Cannot find the declaration of element 'stock'.
```

Corrected: PASS.

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

```text
No error event; warnings:
Could not find schema information for the element 'stock'.
Could not find schema information for the element 'sku'.
```

Corrected: PASS.

### XSDHub libxml2/WASM 0.7.2

```text
Element 'stock': No matching global declaration available for the validation root.
```

Corrected: PASS.

### XSDHub xmlschema 4.3.1 · XSD 1.0

```text
'stock' is not an element of the schema
```

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)
