PARSER ERROR CODES

cvc-complex-type.3.2.2 / cvc-complex-type.4: attributes

XSDHub · Tested 5 November 2026 · How we test guides

Attribute errors have two opposite directions. cvc-complex-type.3.2.2 says an attribute appears where the effective complex type does not permit it. cvc-complex-type.4 says a required attribute is absent. The schema declaration decides which condition applies.

What the message literally means

The first pair writes colour while the type declares color. Correcting the attribute name preserves its blue value. The second pair leaves out id even though use="required" requires it; adding id="A1" satisfies that declaration. A present but empty attribute is a different case and can still fail its own datatype.

Three common causes to check first

  1. The attribute name, case or namespace is wrong. A familiar field label does not guarantee that its expanded attribute name matches the declaration.
  2. A serializer drops required attributes when a source value is null. Check the export rule and data availability instead of changing use to optional automatically.
  3. The document uses an attribute from a different complex type or extension. An attribute allowed on a sibling element may be prohibited on this parent or schema version.

Repair and retest

Locate the effective complex type, including any base type, restriction and attribute groups. Compare each present attribute with its declaration, then inspect use="required" entries for omissions. If a wildcard is involved, check its namespace and processing rules separately. Repair spelling and source mappings, and rerun the whole element to catch value failures after presence checks pass.

When this is a namespace problem

Default namespaces apply to unprefixed element names but not ordinary unprefixed attribute names. Adding xmlns to item does not qualify id. For a qualified attribute declaration, bind and use the correct prefix on that attribute; for an unqualified declaration, an accidental prefix can turn an otherwise correct name into an undeclared attribute.

System.Xml.Schema: undeclared versus required attribute

Keep these two specimens separate when reproducing a production report. Renaming a misspelled required attribute can clear both “not allowed” and “must appear” diagnostics with one edit, but adding a second attribute without removing the wrong one leaves the undeclared-attribute failure behind. Never remove a required identifier just because a different attribute message appeared first.

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.

Undeclared attribute / cvc-complex-type.3.2.2

Broken XML

<item colour="blue"/>
Broken complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:complexType>
      <xs:attribute name="color" type="xs:string"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open broken pair →

Corrected XML

<item color="blue"/>
Corrected complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:complexType>
      <xs:attribute name="color" type="xs:string"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open corrected pair →

Same specimen across engines

EngineBroken: actual reportCorrected
Apache Xerces-J 2.12.2
Validation
cvc-complex-type.3.2.2: Attribute 'colour' is not allowed to appear in element 'item'.
PASS
.NET 8.0.33 · System.Xml.Schema
Validation
The 'colour' attribute is not declared.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2
Validation
Element 'item', attribute 'colour': The attribute 'colour' is not allowed.
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0
Validation
'colour' attribute not allowed for element
PASS
SaxonEE comparison: cvc-complex-type.3.2.2 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

Missing attribute / cvc-complex-type.4

Broken XML

<item/>
Broken complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:complexType>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open broken pair →

Corrected XML

<item id="A1"/>
Corrected complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="item">
    <xs:complexType>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open corrected pair →

Same specimen across engines

EngineBroken: actual reportCorrected
Apache Xerces-J 2.12.2
Validation
cvc-complex-type.4: Attribute 'id' must appear on element 'item'.
PASS
.NET 8.0.33 · System.Xml.Schema
Validation
The required attribute 'id' is missing.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2
Validation
Element 'item': The attribute 'id' is required but missing.
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0
Validation
missing required attribute 'id'
PASS
SaxonEE comparison: cvc-complex-type.4 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