# cvc-id.1 / cvc-id.2: broken ID bindings

An xs:ID value identifies one item within a document; an xs:IDREF refers to such an identifier. Xerces uses cvc-id.1 for a reference with no matching ID and cvc-id.2 when the same ID occurs more than once. These checks depend on the document’s identity relationships.

## Literal meaning

The reference specimen declares item A1 but links to A2, which does not exist. Pointing the link to A1 repairs the binding. The duplicate specimen assigns A1 to two items; assigning A2 to the second item restores uniqueness. Changing an ID in production also requires updating every reference intended to point to that item.

## Three common causes

1. The referenced item was filtered out, moved to another document or renamed without updating its links. IDREF resolution concerns the current document, not a remote business database.
2. Two source records reuse one generated ID. Merging XML fragments can introduce collisions even when each original fragment was internally unique.
3. The schema does not type the relevant fields as xs:ID and xs:IDREF. An ordinary string attribute named id does not automatically acquire schema identity semantics.

## Repair

Collect all typed IDs and references from the complete document, then check uniqueness and missing targets separately. Follow the source record behind each collision before regenerating identifiers. Validate after all referenced records are present; forward references can be legal, so a reference appearing before its target is not itself proof of failure.

## Namespace checks

The ID values in these specimens are identifiers, not namespace-qualified element names. Changing xmlns does not create a missing A2 or make duplicate A1 values unique. Namespaces matter when they prevent an attribute or element from receiving the intended ID datatype; inspect the declaration and qualification before assuming an identity check actually ran.

The measured libxml2/WASM engine returns success for the missing-target specimen, while Xerces, .NET and XSDHub’s server engine reject it. The IDREF buttons therefore select the existing second engine and reveal its unchecked upload-permission control. Loading the pair sends nothing; grant permission and choose Validate XML to run it. Local duplicate-ID checking does fail as shown.

## Unresolved IDREF / cvc-id.1 — Broken

```xml
<catalog>
  <item id="A1"/>
  <link ref="A2"/>
</catalog>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="catalog">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="item" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element>
        <xs:element name="link" minOccurs="0">
          <xs:complexType>
            <xs:attribute name="ref" type="xs:IDREF" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

[Open broken pair](https://xsdhub.com/?example=parser-idref&variant=bad#workbench)

## Unresolved IDREF / cvc-id.1 — Corrected

```xml
<catalog>
  <item id="A1"/>
  <link ref="A1"/>
</catalog>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="catalog">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="item" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element>
        <xs:element name="link" minOccurs="0">
          <xs:complexType>
            <xs:attribute name="ref" type="xs:IDREF" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

[Open corrected pair](https://xsdhub.com/?example=parser-idref&variant=good#workbench)

### Apache Xerces-J 2.12.2

```text
cvc-id.1: There is no ID/IDREF binding for IDREF 'A2'.
```

Corrected: PASS.

### .NET 8.0.33 · System.Xml.Schema

```text
Reference to undeclared ID is 'A2'.
```

Corrected: PASS.

### XSDHub libxml2/WASM 0.7.2

```text
PASS: no validation diagnostic.
```

Corrected: PASS.

### XSDHub xmlschema 4.3.1 · XSD 1.0

```text
IDREF 'A2' not found in XML document
```

Corrected: PASS.

## Duplicate ID / cvc-id.2 — Broken

```xml
<catalog>
  <item id="A1"/>
  <item id="A1"/>
</catalog>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="catalog">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="item" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element>
        <xs:element name="link" minOccurs="0">
          <xs:complexType>
            <xs:attribute name="ref" type="xs:IDREF" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

[Open broken pair](https://xsdhub.com/?example=parser-id-duplicate&variant=bad#workbench)

## Duplicate ID / cvc-id.2 — Corrected

```xml
<catalog>
  <item id="A1"/>
  <item id="A2"/>
</catalog>
```

```xml
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="catalog">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="item" maxOccurs="unbounded">
          <xs:complexType>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element>
        <xs:element name="link" minOccurs="0">
          <xs:complexType>
            <xs:attribute name="ref" type="xs:IDREF" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
```

[Open corrected pair](https://xsdhub.com/?example=parser-id-duplicate&variant=good#workbench)

### Apache Xerces-J 2.12.2

```text
cvc-id.2: There are multiple occurrences of ID value 'A1'.
cvc-attribute.3: The value 'A1' of attribute 'id' on element 'item' is not valid with respect to its type, 'ID'.
```

Corrected: PASS.

### .NET 8.0.33 · System.Xml.Schema

```text
'A1' is already used as an ID.
```

Corrected: PASS.

### XSDHub libxml2/WASM 0.7.2

```text
Element 'item', attribute 'id': 'A1' is not a valid value of the atomic type 'xs:ID'.
```

Corrected: PASS.

### XSDHub xmlschema 4.3.1 · XSD 1.0

```text
attribute id='A1': duplicated xs:ID value 'A1'
```

Corrected: PASS.

Saxon EE was not available; no measured Saxon wording is claimed.

[All parser codes](https://xsdhub.com/learn#parser-error-codes)
[Download engine evidence](https://xsdhub.com/parser-error-examples/engine-evidence.json)
