stevedlawrence commented on code in PR #1604:
URL: https://github.com/apache/daffodil/pull/1604#discussion_r2672466878


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/AlignedMixin.scala:
##########
@@ -321,23 +476,24 @@ trait AlignedMixin extends GrammarMixin { self: Term =>
           case LengthKind.Delimited => encodingLengthApprox
           case LengthKind.Pattern => encodingLengthApprox
           case LengthKind.EndOfParent => LengthMultipleOf(1) // NYI
-          case LengthKind.Prefixed => LengthMultipleOf(1) // NYI
+          case LengthKind.Prefixed => {
+            val prefixElem = eb.prefixedLengthElementDecl
+            if (prefixElem.lengthKind == Explicit) {
+              LengthExact(
+                prefixElem.elementLengthInBitsEv.optConstant.get.get
+              ) + prefixLengthElementLength
+            } else {
+              getEncodingLengthApprox(prefixElem)

Review Comment:
   It doesn't look like `isKnownEncoding` takes into account whether or not an 
element is binary or not. It just accesses the `encodingEv` and asks if it's 
constant. And I think this is the correct behavior, since binary elements can 
have things like initiators that do require encoding. For example:
   
   ```xml
   <element name="foo" type="xs:int"
     dfdl:representation="binary" dfdl:length="4" dfdl:lengthUnits="bytes"
     dfdl:initiator="FOO:" dfdl:encoding="US-ASCII" />
   ```
   This will parse the 4-character ascii string "FOO:" followed by a 4-byte 
two's complement binary integer.
   
   So in some cases, like the example above, it can be reasonable to ask if a 
binary element has a known encoding ad it could be true, so we can't rely on it 
being false for binary numbers. 



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