GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Validator
  • E-invoice
  • Schemas
  • XML formatter Pretty-print or minify XML
  • XML viewer A document as a tree you can search
  • XML to PDF Any XML as a readable PDF
  • XML to JSON Arrays where the XSD allows
  • XPath tester XPath 3.1, matches with their lines
  • JSON to XML @keys as attributes, arrays repeated
  • XSLT transformer XSLT 3.0 with SaxonJS
  • XML to CSV Invoice lines and records as rows
  • XML diff Compare two documents as trees
  • XSD generator An XML Schema from sample XML
  • XML from XSD A sample document from a schema

This view

  • Original page
  • New address

GeezerVison is showing xmlvalid.com — “Invalid attribute for element”: XML error explained | xmlvalid

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>

Check your document

The validator lists every problem with its line and column, and links the ones explained here. It runs in your browser; nothing is uploaded

Open the validator

More RelaxNG errors

  • Did not expect element there
  • Expecting an element, got nothing
  • Type doesn't allow value
All error messages →
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.