Details
-
Improvement
-
Resolution: Fixed
-
Normal
-
None
-
None
Description
Possible better names:
StringMaybeTruncateUnparser
The code itself of this class still is structured as if it was doing padding and truncation with local variable names like nCharsToPad that must be <= 0 now. Those should be touched up to better indicate what this code does, which is when truncation is allowed, truncate the string.
This code assumes the bitLimit will have been set if truncation is to take place. It is unclear if this invariant holds. This invariant needs to be checked. It's possible no truncation will occur in situations where it should. If the type is xs:string the lengthKind is explicit or implicit, and the optTruncateSpecifiedLengthString is defined and true, then we must have a length limit.
Alternatively, this should check and truncate only in that case, but we need to insist this is done consistently. Either the surrounding unparser ALWAYS sets the bit limit (not sure how in case of lengthUnits 'characters'), or this primitive doesn't pay attention to the bit limit and decides itself.
(This idea that the bitLimit setting is how this is detected is a hold-over from the design of the parser which may not be the right choice for the unparser.)