mbeckerle commented on code in PR #1334:
URL: https://github.com/apache/daffodil/pull/1334#discussion_r1819318981


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberTraits.scala:
##########
@@ -103,6 +103,18 @@ trait PrefixedLengthParserMixin {
         "Prefixed length result must be non-negative after 
dfdl:prefixIncludesPrefixLength adjustment , but was: %d",
         adjustedLen
       )
+      // do checks on facets expressed on prefixLengthType
+      val optSTRD = plElement.erd.optSimpleTypeRuntimeData
+      if (optSTRD.isDefined) {
+        val strd = optSTRD.get
+        val check = strd.executeCheck(plElement)
+        if (check.isError) {
+          val pe = state.toProcessingError(
+            s"The calculated value of ${prefixedLengthERD.namedQName} 
($adjustedLen) failed check due to ${check.errMsg}"

Review Comment:
   > @mbeckerle , any word from the WG on this?
   
   No, I've not seen any comments on my email on this subject. 
   
   I think we should just proceed with the decision that the facets are about 
the value that is stored in the prefix integer, not the length of the data. So 
if prefixIncludesPrefixLength is 'true' the value stored is the length of the 
data plus the length of the prefix, and that sum is what the facets are 
constraining. 
   
   So suppose the data is a string with a 2 byte unsigned prefix and 
prefixIncludesPrefixLength is true and the max string length is 1000. Then I 
believe these things hold:
   
   - when parsing: a prefix value of 0 or 1 is malformed and causes a parse 
error
   - when parsing: a prefix value of 2 means zero-length
   - The maxInclusive facet should be 1002, as that means a string  of maximum 
length 1000. 
   - a prefix value of 1003 or above is malformed and causes a parse error. 
   



-- 
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]

Reply via email to