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


##########
daffodil-test/src/test/resources/org/apache/daffodil/layers/xsd/testTwoByteSwap.dfdl.xsd:
##########
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema";
+        xmlns:xs="http://www.w3.org/2001/XMLSchema";
+        xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/";
+        xmlns:dfdlx="http://www.ogf.org/dfdl/dfdl-1.0/extensions";
+        xmlns:fn="http://www.w3.org/2005/xpath-functions";
+        xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
+        xmlns:twobyteSwap="urn:org.apache.daffodil.layers.byteSwap"
+        xmlns:ex="http://example.com";
+        targetNamespace="http://example.com";>
+
+  <include 
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+
+  <xs:import namespace="urn:org.apache.daffodil.layers.byteSwap"
+             
schemaLocation="/org/apache/daffodil/layers/xsd/byteSwapLayer.dfdl.xsd"/>
+
+  <annotation>
+    <appinfo source="http://www.ogf.org/dfdl/";>
+      <dfdl:format ref="ex:GeneralFormat"
+                   representation="binary"
+                   lengthUnits="bits"
+      />
+    </appinfo>
+  </annotation>
+
+  <group name="setVars">
+    <sequence>
+      <annotation><appinfo source="http://www.ogf.org/dfdl/";>
+        <dfdl:setVariable ref="twobyteSwap:requireLengthInWholeWords" 
value="yes"/>
+      </appinfo></annotation>
+    </sequence>
+  </group>
+
+  <element name="TwoByteSwapTest">
+    <complexType>
+      <sequence>
+        <group ref="ex:setVars"/>
+        <element name="len5" dfdl:lengthKind="explicit" dfdl:length="5"
+                 dfdl:lengthUnits="bytes"><!-- note odd fixed length -->
+          <complexType>
+            <sequence>
+              <sequence dfdlx:layer="twobyteSwap:twobyteswap">
+                <element name="Block">
+                  <complexType>
+                    <sequence>
+                      <!-- this will not pull data from the underlying layer 2 
bytes at a time.
+                       Rather, the I/O layer tries to fill this and hits the 
end of data and detects odd length so
+                       causes a PE which ends the array with zero elements in 
it.
+                        That will not cause the layer to fail, just to 
backtrack to the start of the layer data. -->
+                      <element name="Data" type="unsignedShort"
+                               minOccurs="2"
+                               maxOccurs="30"
+                               dfdl:lengthKind="explicit"
+                               dfdl:length="16"
+                               dfdl:occursCountKind="implicit"/>
+                      <!-- Then this optional element is pulled. It will also 
fail due to the odd length of the layer. -->
+                      <element name="postData" type="unsignedByte" 
minOccurs="0"/>
+                    </sequence>
+                  </complexType>
+                </element><!-- end block -->
+              </sequence><!-- end layer -->
+              <!-- this postLayer is after the empty layer
+                 The layer -->

Review Comment:
   typo? Should "The layer" be removed?



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