You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "stevedlawrence (via GitHub)" <gi...@apache.org> on 2024/12/03 17:59:32 UTC

Re: [PR] Enforce HiddenGroupRef not being model group of Complex Type [daffodil]

stevedlawrence commented on code in PR #1380:
URL: https://github.com/apache/daffodil/pull/1380#discussion_r1868176905


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SequenceGroup.scala:
##########
@@ -285,6 +285,17 @@ trait SequenceDefMixin
     }
   }
 
+  lazy val checkHiddenGroupRefNotChildOfComplexType: Unit = {
+    if (hiddenGroupRefOption.isDefined) {
+      optLexicalParent.collect { case _: ComplexTypeBase =>
+        schemaDefinitionError(
+          "A complex type cannot have a sequence with a hiddenGroupRef as its model group. " +
+            "Wrap the hiddenGroupRef sequence in an empty sequence instead."
+        )
+      }
+    }
+  }
+

Review Comment:
   For some reason I had it in my head that looking at the parent of things was to be avoided, maybe that was the reason for all lexical parent stuff? Is it any better to instead do the check in CompelxTypeBase and inspect the model group, e.g.
   
   ```scala
   modelGroup match {
     case s: SequenceGroup => SDEWhen(s.hiddenGroupRefOption.isDefined, ...)
     case => _
   }
   ```
   
   I have no strong preference either way, but I thought accessing parents could caused issues in some cases.



-- 
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: commits-unsubscribe@daffodil.apache.org

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