Invalid attribute for element

An attribute the pattern does not allow, or a required one missing.

The message, as the validator reports it
Invalid attribute lang for element book

Why it happens

  • Invalid attribute: the attribute is not in the schema for this element.
  • failed to validate attributes: a required attribute is missing, or one has a value of the wrong type.

How to fix it

Remove or rename an attribute the schema doesn't know; add a required one; check the value of each against its datatype.

Example

Validated against book.rng, below.

Reports the error
<book isbn="1" lang="en">
  <title>T</title>
  <year>2020</year>
</book>
Fixed
<book isbn="1">
  <title>T</title>
  <year>2020</year>
</book>
book.rng
<element name="book" xmlns="http://relaxng.org/ns/structure/1.0"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <attribute name="isbn"><data type="string"/></attribute>
  <element name="title"><text/></element>
  <element name="year"><data type="gYear"/></element>
</element>