Repository navigation
Conversation
pjfanning
left a comment
There was a problem hiding this comment.
Two non-blocking notes:
- This is a visible behaviour change outside validation too:
setStringValue("1")on such a union now throwsXmlValueOutOfRangeExceptionwhere it used to silently become the booleantrue. I think that is correct, but it deserves a line in the release notes. - The PR description is a single long sentence; splitting it up would make the commit message easier to read later.
|
Both fair. Split the description into short paragraphs, and spelled the setStringValue change out at the end of it so it lands in the squash commit and is ready to lift into the notes: XmlUnionImpl: a union carrying an enumeration facet now rejects a lexical value that its first matching member type accepts but the enumeration does not, so setStringValue may throw XmlValueOutOfRangeException where it previously took a value from a later member. Your reading of it is right: check() only returns false when there's an enumeration, so nothing else can reach the new throw. CHANGES.txt says it hasn't been updated since V5.0.1 and points at status.html, so I've left it untouched rather than reopen it. Say the word if you'd rather the line went there, or somewhere else. |
XmlUnionImpl.set_text tries the union's member types in order. When a member accepted the lexical value but that value was not in the union's enumeration, it carried on to the next member.
XML Schema Datatypes 2.5.1.3 says the first member type that accepts the lexical form gives the union its value, and the enumeration facet is assessed against that value only.
So with
memberTypes='xs:int xs:boolean'and<xs:enumeration value='true'/>, the instance value1is the xs:int 1, which is not enumerated. It was instead reinterpreted as the booleantrueand passed both XmlObject.validate() and ValidatingXMLStreamReader. Xerces reports cvc-enumeration-valid for the same document. The same happened for a union of a list type and an atomic type, and for an attribute of such a type.Found by a differential run of XmlObject.validate() and ValidatingXMLStreamReader against the JDK Xerces validator. After the change the union enumeration disagreements are gone and no other case moves.
The fix stops at the first member that accepts the lexical form and rejects the value if it is not enumerated. Enumerated values, unions with no enumeration, and the non-validating second pass for lexically valid values are unaffected. Regression test added.
Behaviour change worth a release note: on a union that carries an enumeration facet,
setStringValue("1")in the example above now throws XmlValueOutOfRangeException instead of silently becoming the booleantrue. Only unions with an enumeration are affected, and it is the same exception set_text already threw for a value no member accepts.