Project

Profile

Help

Bug #3490

closed

XSD identity constraints with exactly 4 fields will validate incorrectly

Added by Michael Kay over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Schema conformance
Sprint/Milestone:
-
Start date:
2017-10-17
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7, 9.8, trunk
Fix Committed on Branch:
9.7, 9.8, trunk
Fixed in Maintenance Release:
Platforms:

Description

The class ValueEntry4 is used to hold key values when there are exactly four fields in the constraint. The equals() method for ValueEntry4 says:

        public boolean equals(Object obj) {
            return obj instanceof ValueEntry3 &&
                    compareValues(value0, ((ValueEntry4) obj).value0) &&
                    compareValues(value1, ((ValueEntry4) obj).value1) &&
                    compareValues(value1, ((ValueEntry4) obj).value2) &&
                    compareValues(value2, ((ValueEntry4) obj).value3);
        }

The first condition (obj instanceof ValueEntry3) will never be true, so the keys will never be equal, so xs:unique and xs:key will fail to report duplicates. Conversely, an xs:keyRef constraint with exactly four fields will never be satisfied.

(Spotted in the code; no test case has actually failed.)

Please register to edit this issue

Also available in: Atom PDF