You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2020/07/16 16:00:08 UTC

[GitHub] [incubator-daffodil] stevedlawrence opened a new pull request #400: Add tests showing multiple discriminator behavior

stevedlawrence opened a new pull request #400:
URL: https://github.com/apache/incubator-daffodil/pull/400


   One test currently fails when multiple discriminators evaluate to true
   followed by a parser error that requires backtracking. The multiple
   discriminators do not resolve the correct points of uncertainty.
   
   DAFFODIL-2371


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-daffodil] stevedlawrence commented on a change in pull request #400: Add tests showing multiple discriminator behavior

Posted by GitBox <gi...@apache.org>.
stevedlawrence commented on a change in pull request #400:
URL: https://github.com/apache/incubator-daffodil/pull/400#discussion_r456379537



##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/multipleDiscriminators.tdml
##########
@@ -0,0 +1,171 @@
+<?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.
+-->
+
+<tdml:testSuite xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ex="http://example.com"
+  suiteName="multipleDiscriminators">
+
+  <tdml:defineSchema name="multipleDiscriminators">
+
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+
+    <dfdl:format ref="ex:GeneralFormatPortable" />
+
+    <xs:element name="root">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="discrim1" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+          <xs:element name="discrim2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+          <xs:choice>
+            <xs:element name="outerBranch1">
+              <xs:complexType>
+                <xs:choice>
+                  <xs:element name="innerBranch1">
+                    <xs:complexType>
+                      <xs:sequence>
+                        <xs:sequence>
+                          <xs:annotation>
+                            <xs:appinfo source="http://www.ogf.org/dfdl/">
+                              <dfdl:discriminator test="{ ../../ex:discrim1 eq 't' }" />
+                            </xs:appinfo>
+                          </xs:annotation>
+                        </xs:sequence>
+                        <xs:sequence>
+                          <xs:annotation>
+                            <xs:appinfo source="http://www.ogf.org/dfdl/">
+                              <dfdl:discriminator test="{ ../../ex:discrim2 eq 't' }" />
+                            </xs:appinfo>
+                          </xs:annotation>
+                        </xs:sequence>
+                        <xs:element name="integer" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="1" />
+                      </xs:sequence>
+                    </xs:complexType>
+                  </xs:element>
+                  <xs:element name="innerBranch2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+                </xs:choice>
+              </xs:complexType>
+            </xs:element>
+            <xs:element name="outerBranch2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+          </xs:choice>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <!--
+    The first discriminator evaluates to false, causing immediate backtracking.
+    The second discriminator is never evaluated.
+    We speculatively parse innerBranch2, and it is successful.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators1" model="multipleDiscriminators" root="root">
+    <tdml:document>ffa</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>f</discrim1>
+          <discrim2>f</discrim2>
+          <outerBranch1>
+            <innerBranch2>a</innerBranch2>
+          </outerBranch1>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+  
+  <!--
+    The first discriminator evaluates to false, causing immediate backtracking.
+    The second discriminator is never evaluated.
+    We speculatively parse innerBranch2, and it is successful.
+    Exactly he same behavior as multipleDiscriminators1.
+    -->
+  <tdml:parserTestCase name="multipleDiscriminators2" model="multipleDiscriminators" root="root">
+    <tdml:document>fta</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>f</discrim1>
+          <discrim2>t</discrim2>
+          <outerBranch1>
+            <innerBranch2>a</innerBranch2>
+          </outerBranch1>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    The first discriminator evaluates to true, resolving the inner choice PoU.
+    The second discriminator evaluates to false, causing immediate backtracking.
+    Because the inner choice PoU is resolved, we backtrack to the outer choice.
+    We speculatively parse outerBranch2 and it is successful.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators3" model="multipleDiscriminators" root="root">
+    <tdml:document>tfa</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>t</discrim1>
+          <discrim2>f</discrim2>
+          <outerBranch2>a</outerBranch2>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    The first discriminator evaluates to true, resolving the inner choice PoU.
+    The second discriminator evaluates to true, resolving the outer choice PoU.
+    We successfully parse the integer element. No backtracking is neeeded.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators4" model="multipleDiscriminators" root="root">
+    <tdml:document>tt1</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>t</discrim1>
+          <discrim2>t</discrim2>
+          <outerBranch1>
+            <innerBranch1>
+              <integer>1</integer>
+            </innerBranch1>
+          </outerBranch1>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    The first discriminator evaluates to true, resolving the inner choice PoU.
+    The second discriminator evaluates to true, resolving the outer choice PoU.
+    We attempt to parse the interger element, which fails, creating a Parse Error and immediately backtrack.
+    Because the inner choice PoU is resolved, we backtrack to the outer choice.
+    Because the outer choice PoU is resolved, we backtrack again, but there are
+    no more PoU's. It is a Parse Error related to the failure to parse the
+    interger element.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators5" model="multipleDiscriminators" root="root">
+    <tdml:document>tta</tdml:document>
+    <tdml:errors>
+      <tdml:error>interger</tdml:error>

Review comment:
       Yep, that should be "integer" to match the element name related to the parser error. Good catch. Will fix.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-daffodil] tuxji commented on a change in pull request #400: Add tests showing multiple discriminator behavior

Posted by GitBox <gi...@apache.org>.
tuxji commented on a change in pull request #400:
URL: https://github.com/apache/incubator-daffodil/pull/400#discussion_r456134348



##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/multipleDiscriminators.tdml
##########
@@ -0,0 +1,171 @@
+<?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.
+-->
+
+<tdml:testSuite xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ex="http://example.com"
+  suiteName="multipleDiscriminators">
+
+  <tdml:defineSchema name="multipleDiscriminators">
+
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+
+    <dfdl:format ref="ex:GeneralFormatPortable" />
+
+    <xs:element name="root">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="discrim1" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+          <xs:element name="discrim2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+          <xs:choice>
+            <xs:element name="outerBranch1">
+              <xs:complexType>
+                <xs:choice>
+                  <xs:element name="innerBranch1">
+                    <xs:complexType>
+                      <xs:sequence>
+                        <xs:sequence>
+                          <xs:annotation>
+                            <xs:appinfo source="http://www.ogf.org/dfdl/">
+                              <dfdl:discriminator test="{ ../../ex:discrim1 eq 't' }" />
+                            </xs:appinfo>
+                          </xs:annotation>
+                        </xs:sequence>
+                        <xs:sequence>
+                          <xs:annotation>
+                            <xs:appinfo source="http://www.ogf.org/dfdl/">
+                              <dfdl:discriminator test="{ ../../ex:discrim2 eq 't' }" />
+                            </xs:appinfo>
+                          </xs:annotation>
+                        </xs:sequence>
+                        <xs:element name="integer" type="xs:int" dfdl:lengthKind="explicit" dfdl:length="1" />
+                      </xs:sequence>
+                    </xs:complexType>
+                  </xs:element>
+                  <xs:element name="innerBranch2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+                </xs:choice>
+              </xs:complexType>
+            </xs:element>
+            <xs:element name="outerBranch2" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="1" />
+          </xs:choice>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <!--
+    The first discriminator evaluates to false, causing immediate backtracking.
+    The second discriminator is never evaluated.
+    We speculatively parse innerBranch2, and it is successful.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators1" model="multipleDiscriminators" root="root">
+    <tdml:document>ffa</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>f</discrim1>
+          <discrim2>f</discrim2>
+          <outerBranch1>
+            <innerBranch2>a</innerBranch2>
+          </outerBranch1>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+  
+  <!--
+    The first discriminator evaluates to false, causing immediate backtracking.
+    The second discriminator is never evaluated.
+    We speculatively parse innerBranch2, and it is successful.
+    Exactly he same behavior as multipleDiscriminators1.
+    -->
+  <tdml:parserTestCase name="multipleDiscriminators2" model="multipleDiscriminators" root="root">
+    <tdml:document>fta</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>f</discrim1>
+          <discrim2>t</discrim2>
+          <outerBranch1>
+            <innerBranch2>a</innerBranch2>
+          </outerBranch1>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    The first discriminator evaluates to true, resolving the inner choice PoU.
+    The second discriminator evaluates to false, causing immediate backtracking.
+    Because the inner choice PoU is resolved, we backtrack to the outer choice.
+    We speculatively parse outerBranch2 and it is successful.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators3" model="multipleDiscriminators" root="root">
+    <tdml:document>tfa</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>t</discrim1>
+          <discrim2>f</discrim2>
+          <outerBranch2>a</outerBranch2>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    The first discriminator evaluates to true, resolving the inner choice PoU.
+    The second discriminator evaluates to true, resolving the outer choice PoU.
+    We successfully parse the integer element. No backtracking is neeeded.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators4" model="multipleDiscriminators" root="root">
+    <tdml:document>tt1</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <root>
+          <discrim1>t</discrim1>
+          <discrim2>t</discrim2>
+          <outerBranch1>
+            <innerBranch1>
+              <integer>1</integer>
+            </innerBranch1>
+          </outerBranch1>
+        </root>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    The first discriminator evaluates to true, resolving the inner choice PoU.
+    The second discriminator evaluates to true, resolving the outer choice PoU.
+    We attempt to parse the interger element, which fails, creating a Parse Error and immediately backtrack.
+    Because the inner choice PoU is resolved, we backtrack to the outer choice.
+    Because the outer choice PoU is resolved, we backtrack again, but there are
+    no more PoU's. It is a Parse Error related to the failure to parse the
+    interger element.
+  -->
+  <tdml:parserTestCase name="multipleDiscriminators5" model="multipleDiscriminators" root="root">
+    <tdml:document>tta</tdml:document>
+    <tdml:errors>
+      <tdml:error>interger</tdml:error>

Review comment:
       Is "interger" spelled correctly?  A grep shows me no occurrences of "interger" in my incubator-daffodil checkout and a find in page tells me "interger" occurs only 3 times in this page (two times in the test case comment, one time inside the test case).  Since I see an "interger" element defined in the test schema, I assume you meant "integer" instead of "interger".




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-daffodil] stevedlawrence merged pull request #400: Add tests showing multiple discriminator behavior

Posted by GitBox <gi...@apache.org>.
stevedlawrence merged pull request #400:
URL: https://github.com/apache/incubator-daffodil/pull/400


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org