This is an automated email from the ASF dual-hosted git repository.
olabusayo 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 a48d92f43 Ensure hidden groups children excluded from siblings list
a48d92f43 is described below
commit a48d92f436fec186f8e8f12a784177b126d2a5e9
Author: olabusayoT <[email protected]>
AuthorDate: Fri Oct 4 20:58:29 2024 -0400
Ensure hidden groups children excluded from siblings list
- currently we don't exclude the children of hidden groups from the
siblings list. This is because we do the check for when a groupRef is hidden
after ChoiceTermBase. The issue is ChoiceGroupRef and SequenceGroupRef, which
are GroupRefs, also extend ChoiceTermBase and SequenceTermBase, so it's
imperative that we do the hidden check before the *TermBases check
- add unit test to verify the hidden group's children are excluded from the
sibling list
DAFFODIL-2937
---
.../daffodil/core/runtime1/TermRuntime1Mixin.scala | 2 +-
.../TestStreamingUnparserCompilerAttributes.scala | 45 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git
a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/TermRuntime1Mixin.scala
b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/TermRuntime1Mixin.scala
index 2d25012c7..cc1d1f305 100644
---
a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/TermRuntime1Mixin.scala
+++
b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/TermRuntime1Mixin.scala
@@ -286,6 +286,7 @@ trait TermRuntime1Mixin { self: Term =>
Closed(Seq(PNE(eb, true)))
case eb: ElementBase =>
Open(Seq(PNE(eb, false)))
+ case gr: GroupRef if gr.isHidden => Open(Nil)
case ctb: ChoiceTermBase => {
val individualBranchPossibles = ctb.groupMembers.map {
_.possibleSelfPlusNextLexicalSiblingStreamingUnparserElements
@@ -326,7 +327,6 @@ trait TermRuntime1Mixin { self: Term =>
}
res
}
- case gr: GroupRef if gr.isHidden => Open(Nil)
case stb: SequenceTermBase => {
//
// This case only applies to when we are analyzing a sequence, but
it is
diff --git
a/daffodil-core/src/test/scala/org/apache/daffodil/core/runtime1/TestStreamingUnparserCompilerAttributes.scala
b/daffodil-core/src/test/scala/org/apache/daffodil/core/runtime1/TestStreamingUnparserCompilerAttributes.scala
index 85fd479fc..c8780f043 100644
---
a/daffodil-core/src/test/scala/org/apache/daffodil/core/runtime1/TestStreamingUnparserCompilerAttributes.scala
+++
b/daffodil-core/src/test/scala/org/apache/daffodil/core/runtime1/TestStreamingUnparserCompilerAttributes.scala
@@ -385,6 +385,51 @@ class TestStreamingUnparserCompilerAttributes {
val Closed(Seq(PNE(`c`, true))) = poss(c)
}
+// DAFFODIL-2937
+ @Test def testPossibleNextStreamingUnparserEvent12() = {
+ val r = getRoot {
+ <xs:element name="root">
+ <xs:complexType>
+ <xs:group ref="ex:g2" dfdl:separator="%NL;"></xs:group>
+ </xs:complexType>
+ </xs:element>
+ <xs:group name="g2">
+ <xs:sequence dfdl:separatorPosition="infix">
+ <xs:element name="g2c0" type="xs:string" />
+ <xs:element name="g2c1" type="xs:string" />
+ <xs:element name="g2c2" type="xs:string" maxOccurs="unbounded" />
+ <xs:sequence dfdl:hiddenGroupRef="ex:hg" />
+ <xs:group ref="ex:vg" />
+ </xs:sequence>
+ </xs:group>
+ <xs:group name="hg">
+ <xs:choice>
+ <xs:element name="hg_inty" type="xs:int"
+ dfdl:lengthKind="delimited" dfdl:outputValueCalc="{ 1
}" />
+ <xs:element name="hg_stringy" type="xs:string"
+ dfdl:lengthKind="delimited" />
+ </xs:choice>
+ </xs:group>
+ <xs:group name="vg">
+ <xs:choice>
+ <xs:element name="vg_inty" type="xs:int"
+ dfdl:lengthKind="delimited" />
+ <xs:element name="vg_stringy" type="xs:string"
+ dfdl:lengthKind="delimited" />
+ </xs:choice>
+ </xs:group>
+ }
+ val rg: SGR = r.complexType.group.asInstanceOf[SequenceGroupRef]
+ val Seq(g2c1: LE, g2c2: LE, g2c3: LE, hg: CGR, vg: CGR) = rg.groupMembers
+ val Closed(Seq(PNE(`g2c1`, true))) = poss(g2c1)
+ val Closed(Seq(PNE(`g2c2`, true))) = poss(g2c2)
+ val Closed(Seq(PNE(`g2c3`, false), PNE(vg_inty, false), PNE(vg_stringy,
false))) = poss(
+ g2c3
+ )
+ val Open(Seq(PNE(`vg_inty`, false), PNE(`vg_stringy`, false))) = poss(hg)
+ val Closed(Seq(PNE(`vg_inty`, false), PNE(`vg_stringy`, false))) = poss(vg)
+ }
+
@Test def testPossibleNextStreamingUnparserEventHidden1() = {
val r = getRoot {
<xs:element name="r">