This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new 36b98fc2d Add test showing optional elements cannot have predicates in
expressions
36b98fc2d is described below
commit 36b98fc2d78b0485af614202b4cd0c51cec9a2e3
Author: Steve Lawrence <[email protected]>
AuthorDate: Tue Mar 12 12:28:18 2024 -0400
Add test showing optional elements cannot have predicates in expressions
Optional elements used to be implemented as arrays with a max size of
one. A side effect of this was that accessing these elements in an
expression required a predicate (e.g. /path/to/optional[1]).
However, at some point we changed the implementation so optional
elements were no longer arrays and were added to the infoset just like
scalars. This change also meant they no longer needed, or were allowed
to have, predicates in expressions. This adds a test to confirm that
behavior.
This also adds a colon to "subset" error messages to make the actual
error message more clear.
DAFFODIL-2013
---
.../org/apache/daffodil/runtime1/dsom/SDE.scala | 2 +-
.../unordered_sequences/UnorderedSequences.tdml | 2 +-
.../section23/dfdl_expressions/expressions.tdml | 31 ++++++++++++++++++++--
.../dfdl_expressions/TestDFDLExpressions.scala | 1 +
4 files changed, 32 insertions(+), 4 deletions(-)
diff --git
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/SDE.scala
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/SDE.scala
index 3367b784c..a0898dca8 100644
---
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/SDE.scala
+++
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/SDE.scala
@@ -279,7 +279,7 @@ trait ImplementsThrowsOrSavesSDE extends
ImplementsThrowsSDE with SavesErrorsAnd
def subsetError(msg: String, args: Any*) = {
val msgTxt = msg.format(args: _*)
- SDE("Subset " + msgTxt)
+ SDE("Subset: " + msgTxt)
}
}
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/UnorderedSequences.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/UnorderedSequences.tdml
index 18001c388..e97d67ff5 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/UnorderedSequences.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/UnorderedSequences.tdml
@@ -627,7 +627,7 @@
<tdml:document><![CDATA[a1,b2,cy99:x20:z10]]></tdml:document>
<tdml:errors>
<tdml:error>Schema Definition Error</tdml:error>
- <tdml:error>Subset Indexing is only allowed on arrays</tdml:error>
+ <tdml:error>Subset: Indexing is only allowed on arrays</tdml:error>
</tdml:errors>
</tdml:parserTestCase>
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
index a1f634e46..140479e89 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_expressions/expressions.tdml
@@ -4322,6 +4322,16 @@ blastoff
</xs:complexType>
</xs:element>
+ <xs:element name="e6">
+ <xs:complexType>
+ <xs:sequence dfdl:separator=",">
+ <xs:element name="index" type="xs:int" />
+ <xs:element name="item" type="xs:string" minOccurs="0"
maxOccurs="1"/>
+ <xs:element name="p" type="xs:string" dfdl:inputValueCalc="{
/ex:e6/ex:item[1] }"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
</tdml:defineSchema>
<!--
@@ -4426,7 +4436,24 @@ blastoff
<tdml:document>2,one,two,three</tdml:document>
<tdml:errors>
<tdml:error>Schema Definition Error</tdml:error>
- <tdml:error>Subset Indexing is only allowed on arrays.</tdml:error>
+ <tdml:error>Subset: Indexing is only allowed on arrays.</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+
+ <!--
+ Test Name: predicate_06
+ Schema: predicates
+ Root: e6
+ Purpose: This test demonstrates that subset indexing is not allowed on
optionals
+ -->
+
+ <tdml:parserTestCase name="predicate_06" root="e6"
+ model="predicates" description="Section 23 - DFDL Expressions -
DFDL-23-067R">
+
+ <tdml:document>2,one</tdml:document>
+ <tdml:errors>
+ <tdml:error>Schema Definition Error</tdml:error>
+ <tdml:error>Subset: Indexing is only allowed on arrays.</tdml:error>
</tdml:errors>
</tdml:parserTestCase>
@@ -7270,7 +7297,7 @@ blastoff
<tdml:document>1,2,3</tdml:document>
<tdml:errors>
<tdml:error>Schema Definition Error</tdml:error>
- <tdml:error>Subset Indexing is only allowed on arrays</tdml:error>
+ <tdml:error>Subset: Indexing is only allowed on arrays</tdml:error>
<tdml:error>ex:a</tdml:error>
</tdml:errors>
</tdml:parserTestCase>
diff --git
a/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
b/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
index 74c88421e..9782d013c 100644
---
a/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
+++
b/daffodil-test/src/test/scala/org/apache/daffodil/section23/dfdl_expressions/TestDFDLExpressions.scala
@@ -529,6 +529,7 @@ class TestDFDLExpressions {
// @Test def test_predicate_03() { runner.runOneTest("predicate_03") }
@Test def test_predicate_04(): Unit = { runner.runOneTest("predicate_04") }
@Test def test_predicate_05(): Unit = { runner.runOneTest("predicate_05") }
+ @Test def test_predicate_06(): Unit = { runner.runOneTest("predicate_06") }
@Test def test_sequential_and_01(): Unit = {
runner.runOneTest("sequential_and_01") }
@Test def test_sequential_and_02(): Unit = {
runner.runOneTest("sequential_and_02") }