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


##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SequenceGroup.scala:
##########
@@ -215,19 +216,39 @@ 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
+  private lazy val checkUnorderedSequenceMembersHaveUniqueNamesInNamespaces: 
Unit = {
+    val nonUniqueNameChildren =
+      checkMembersHaveUniqueNamesInNamespaces.filter(_._1 == true).values
+    nonUniqueNameChildren.foreach { children =>
+      children.head.SDE(
+        "Two or more members of an unordered sequence have the same name and 
the same namespace"
+      )
     }
-    childrenGroupedByQName.foreach { case (qname, children) =>
-      if (children.length > 1) {
-        children.head.SDE(
-          "Two or more members of an unordered sequence have the same name and 
the same namespace"
-        )
+  }
+
+  private lazy val checkMembersHaveUniqueNamesInNamespaces: Map[Boolean, 
Seq[Term]] = {
+    val childrenGroupedByQName = groupMembers
+      .filter { m => m.isInstanceOf[LocalElementDecl] || 
m.isInstanceOf[ElementRef] }
+      .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.map { case (qname, children) =>
+      (children.length > 1, children)
+    }
+  }
+
+  private lazy val checkIfMultipleChildrenWithSameName: Unit = {
+    val nonUniqueNameChildren =
+      checkMembersHaveUniqueNamesInNamespaces.filter(_._1 == true).values
+    nonUniqueNameChildren.foreach { children =>
+      children.head.SDW(
+        WarnID.MultipleChildElementsWithSameName,

Review Comment:
   +1 
   You are correct this is not about "what the current infoset supports", but 
about making sure a user knows their schema describes an infoset that will not 
work in conjunction with JSON or Java POJOs, or SQL databases, or whatever. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to