# The attribute is not declared

Source: https://xmlvalid.com/errors/attribute-is-not-declared

> An element carries an attribute its type in the schema does not declare.

The message, as .NET reports it: `The 'vat' attribute is not declared.`

## Why it happens

- A misspelt attribute name or a different letter case.
- An attribute from a newer version of the format, validated against an older schema.

## How to fix it

- Remove or rename the attribute, or validate against the schema version the document was written for. The message doesn't name the element: the line and position in `ValidationEventArgs.Exception` do.
- .NET throws an `XmlSchemaValidationException` at the first schema error unless `XmlReaderSettings.ValidationEventHandler` is set, which then receives every one with its line and position. A well-formedness error is an `XmlException` and ends reading whatever the settings.

## The same problem in xmlvalid

libxml2, which xmlvalid validates with, reports it as [The attribute is not allowed](https://xmlvalid.com/errors/attribute-is-not-allowed): `Element 'order', attribute 'vat': The attribute 'vat' is not allowed.`

## Example that fails

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

## Fixed

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