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 — “[facet 'maxLength'] The value exceeds the allowed… | xmlvalid

[facet 'maxLength'] The value exceeds the allowed length

A value longer (or shorter) than the schema allows

The message, as the validator reports it
Element 'note': [facet 'maxLength'] The value has a length of '17'; this exceeds the allowed maximum length of '10'.

Why it happens

  • Free text longer than a field allows: names, addresses, references.
  • Length is counted in characters, not bytes, after whitespace handling for the type.

How to fix it

Shorten the value to the limit the message gives (or lengthen it for minLength). Truncate deliberately where the data is produced rather than letting another system cut it.

Example

Validated against order.xsd, below.

Reports the error
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <note>far too long text</note>
</order>
Fixed
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <note>short</note>
</order>
order.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="order">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id" type="xs:string"/>
        <xs:element name="qty" type="xs:int"/>
        <xs:element name="status" type="Status" minOccurs="0"/>
        <xs:element name="code" type="Code" minOccurs="0"/>
        <xs:element name="note" type="Short" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="currency" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:simpleType name="Status">
    <xs:restriction base="xs:string">
      <xs:enumeration value="open"/>
      <xs:enumeration value="paid"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Code">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z]{3}-[0-9]{4}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Short">
    <xs:restriction base="xs:string">
      <xs:maxLength value="10"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

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

In Java and .NET

  • cvc-maxLength-valid: Value with length is not facet-valid with respect to maxLength (Java)
  • The actual length is greater than the MaxLength value (.NET)

More XML Schema (XSD) errors

  • This element is not expected
  • Is not a valid value of the atomic type
  • Missing child element(s)
  • The attribute is required but missing
  • The attribute is not allowed
  • No matching global declaration available for the validation root
All error messages →
You are visitor 01402792 — 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.