olabusayoT commented on code in PR #1176:
URL: https://github.com/apache/daffodil/pull/1176#discussion_r1520320478


##########
daffodil-test/src/test/resources/org/apache/daffodil/layers/exampleCheckDigit.dfdl.xsd:
##########
@@ -45,36 +45,44 @@
       <sequence>
         <annotation>
           <appinfo source="http://www.ogf.org/dfdl/";>
+            <!-- This variable must live on past the end of the layer -->
             <dfdl:newVariableInstance ref="cd:checkDigit"/>
-            <dfdl:newVariableInstance ref="cd:checkDigitParams" 
defaultValue="verbose"/>
           </appinfo>
         </annotation>
+        <sequence dfdlx:layer="cd:checkDigit">
+          <annotation>
+            <appinfo source="http://www.ogf.org/dfdl/";>
+              <!--
+              These variables are just parameters to the layer logic, so can be
+              scoped to end exactly with the end of the layer.
+              -->
+              <dfdl:newVariableInstance ref="cd:params" 
defaultValue="verbose"/>
+              <dfdl:newVariableInstance ref="cd:digitEncoding" 
defaultValue="ascii"/>
+              <dfdl:newVariableInstance ref="cd:length" defaultValue="10"/>
+            </appinfo>
+          </annotation>
+          <element name="value" type="ex:dateType"/>
+        </sequence>
+        <element name="checkDigit" type="cd:checkDigitType" dfdl:initiator=":"
+                 dfdl:outputValueCalc='{ $cd:checkDigit }'/>
+        <element name="computedCheckDigit" type="cd:checkDigitType"
+                 dfdl:inputValueCalc='{ $cd:checkDigit }'/>
         <sequence>
-          <sequence dfdl:ref="cd:checkDigitExplicit" dfdlx:layerLength="10">
-            <element name="value" type="tns:dateType"/>
-          </sequence>
-          <element name="checkDigit" type="cd:checkDigitType" 
dfdl:initiator=":"
-                   dfdl:outputValueCalc='{ $cd:checkDigit }'/>
-          <element name="computedCheckDigit" type="cd:checkDigitType"
-                   dfdl:inputValueCalc='{ $cd:checkDigit }'/>
-          <sequence>
-            <annotation>
-              <appinfo source="http://www.ogf.org/dfdl/";>
-                <dfdl:assert
-                  failureType="recoverableError"
-                  test='{ checkDigit eq $cd:checkDigit }'
-                  message='{ fn:concat("Incorrect check digit: ", checkDigit, 
". Should be: ", $cd:checkDigit, ".") }' />
-              </appinfo>
-            </annotation>
-          </sequence>
+          <annotation>
+            <appinfo source="http://www.ogf.org/dfdl/";>
+              <dfdl:assert
+                failureType="recoverableError"
+                test='{ checkDigit eq $cd:checkDigit }'
+                message='{ fn:concat("Incorrect check digit: ", checkDigit, ". 
Should be: ", $cd:checkDigit, ".") }'/>

Review Comment:
   In a separate project, we established that xmlllint didn't recognize the 
asserts as validation errors and decided instead to use an "invalid" element 
that only showed up when the checksum/checkdigit was incorrect, and had an enum 
facet that would always fail. I think showing that in this example might be the 
better approach.



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