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
Human-readable formatting entered a machine-readable field. Words, thousands separators or locale-specific decimal punctuation can be invalid for the declared XSD datatype.
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.
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.
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
Saxon
EE 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.
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.