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/11/13 13:48:38 UTC

Re: [PR] Warn about Multiple Child Elements with Same Name [daffodil]

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


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SequenceGroup.scala:
##########
@@ -215,20 +216,37 @@ abstract class SequenceGroupTermBase(xml: Node, lexicalParent: SchemaComponent,
     }
   }
 
-  private lazy val checkMembersHaveUniqueNamesInNamespaces: Unit = {
-    val childrenGroupedByQName = groupMembers.groupBy { gm =>
-      // previous checks should ensure that all group members are either local
-      // elements or element references
-      Assert.invariant(gm.isInstanceOf[ElementBase])
-      gm.asInstanceOf[ElementBase].namedQName
-    }
-    childrenGroupedByQName.foreach { case (qname, children) =>
-      if (children.length > 1) {
+  private lazy val checkUnorderedSequenceMembersHaveUniqueNamesInNamespaces: Unit = {
+    // previous checks should ensure that all group members for unordered sequences are either local
+    // elements or element references
+    groupChildrenBy(_.namedQName)

Review Comment:
   I forget why we added the `groupChildrenBy` function, but it only replaces `elementChildren.groupBy`. The former isn't significantly shorter and I don't think it is any more clear. Is it worth removing `groupChildrenBy`?



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