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
The attribute name, case or namespace is wrong. A familiar field label does not guarantee that its expanded attribute name matches the declaration.
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.
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.
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
Saxon
EE 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.
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
Saxon
EE 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.
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.