PARSER ERROR CODES

cvc-type.3.1.3 / cvc-datatype-valid.1.2.1: invalid value

XSDHub · Tested 5 November 2026 · How we test guides

These two Xerces messages can describe one bad value at different levels. cvc-datatype-valid.1.2.1 identifies a lexical value that does not belong to the selected atomic datatype. cvc-type.3.1.3 then reports the containing element’s value as invalid.

What the message literally means

The text two cannot be interpreted as an xs:integer. Xerces reports both the datatype failure and the element-value failure for count, while other engines may issue only one diagnostic. Replacing two with 2 repairs the lexical representation without altering the declaration or switching the type to string.

Three common causes to check first

  1. Human-readable formatting entered a machine-readable field. Words, thousands separators or locale-specific decimal punctuation can be invalid for the declared XSD datatype.
  2. An empty or whitespace-only element was emitted for a required numeric or date value. Presence of a tag does not manufacture a valid typed value.
  3. The producer uses a different type contract from the receiver. A decimal-looking identifier or timestamp may be legal text but incompatible with the type selected in this schema version.

Repair and retest

Read the earliest datatype or facet diagnostic before the broader element-value message. Extract the exact text after XML entity expansion and whitespace processing, then compare it with the declared simple type and its base. Correct serialization at the field boundary. Preserve the schema’s meaning: changing xs:integer to xs:string would discard numeric validation rather than repair the export.

When this is a namespace problem

This example reaches the correct count declaration, so its failure is not caused by a missing namespace. Namespaces matter when xsi:type selects another type or the document is validated against an unintended vocabulary. If the reported type surprises you, trace type selection before editing values.

Reading equivalent reports

A paired Xerces report is not evidence of two independent corrupt fields. In the transcript both messages refer to count and disappear together after one text change. If the value already belongs to the base datatype, inspect restriction facets such as pattern, enumeration and length instead of forcing a numeric conversion.

Complete tested XML and XSD pairs

Open either variant in the workbench, then choose Validate XML. Loading an example does not run validation or send documents; server checks require the existing permission checkbox.

These transcripts were captured on 5 November 2026 from the exact files shown below. Download all measured results and SHA-256 hashes.

Invalid datatype / cvc-type.3.1.3

Broken XML

<count>two</count>
Broken complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="count" type="xs:integer"/>
</xs:schema>

Download XML · Download XSD

Open broken pair →

Corrected XML

<count>2</count>
Corrected complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="count" type="xs:integer"/>
</xs:schema>

Download XML · Download XSD

Open corrected pair →

Same specimen across engines

EngineBroken: actual reportCorrected
Apache Xerces-J 2.12.2
Validation
cvc-datatype-valid.1.2.1: 'two' is not a valid value for 'integer'.
cvc-type.3.1.3: The value 'two' of element 'count' is not valid.
PASS
.NET 8.0.33 · System.Xml.Schema
Validation
The 'count' element is invalid - The value 'two' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:integer' - The string 'two' is not a valid Integer value.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2
Validation
Element 'count': 'two' is not a valid value of the atomic type 'xs:integer'.
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0
Validation
invalid literal for int() with base 10: 'two'
PASS
SaxonEE comparison: cvc-datatype-valid.1.2.1, cvc-type.3.1.3 describes the corresponding XSD constraint. No Saxon-EE run or wording is claimed; an EE licence is unavailable in this test environment. Saxon-HE does not provide XSD validation.Not run

Saxon comparison and test scope

Saxonica documents XSD processing as an Enterprise Edition feature. The Saxon rows map the named constraint, rather than presenting an invented message. The four measured rows are Xerces, .NET, the shipped workbench engine and XSDHub’s second engine.

The corrected results apply to these self-contained XSD 1.0 specimens. They do not establish business-rule acceptance for a different document or schema version.

Continue the diagnosis

All parser error codes · XML and XSD validator

Primary references