stevedlawrence commented on code in PR #1192:
URL: https://github.com/apache/daffodil/pull/1192#discussion_r1539122622
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala:
##########
@@ -407,7 +416,32 @@ final class SimpleTypeRuntimeData(
// Note: dont check occurs counts // if(!checkMinMaxOccurs(e,
pstate.arrayIterationPos)) { return java.lang.Boolean.FALSE }
OK
}
+ private def checkLength(
+ diNode: DISimple,
+ lenValue: java.math.BigDecimal,
+ e: ThrowsSDE,
+ primType: PrimType,
+ ): java.lang.Boolean = {
+ val lenAsLong = lenValue.longValueExact()
+ primType match {
+ case PrimType.String => {
+ val data = diNode.dataValue.getString
+ val dataLen = data.length.toLong
+ val isDataLengthEqual = dataLen.compareTo(lenAsLong) == 0
+ if (isDataLengthEqual) java.lang.Boolean.TRUE
+ else java.lang.Boolean.FALSE
+ }
+ case PrimType.HexBinary => {
+ val data = diNode.dataValue.getByteArray
+ val dataLen = data.length.toLong
+ val isDataLengthEqual = dataLen.compareTo(lenAsLong) == 0
Review Comment:
Found this in the XSD spec:
> 1.2 if [{primitive type
definition}](https://www.w3.org/TR/xmlschema11-2/#std-primitive_type_definition)
is [hexBinary](https://www.w3.org/TR/xmlschema11-2/#hexBinary) or
[base64Binary](https://www.w3.org/TR/xmlschema11-2/#base64Binary), then the
length of the value, as measured in octets of the binary data,
[must](https://www.w3.org/TR/xmlschema11-2/#dt-must) be equal to
[{value}](https://www.w3.org/TR/xmlschema11-2/#f-l-value);
So what we have is correct since we are checking the number of bytes. I'm
still not sure why min/maxLength use equals for minLength/maxLength, feels like
a bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]