olabusayoT commented on code in PR #1321:
URL: https://github.com/apache/daffodil/pull/1321#discussion_r1778962623
##########
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:
I think I prefer the idea of MultipleChildElementsWithSameName subsuming
NamespaceDifferencesOnly instead of the other way around, because in sequence
group, the namespaces could be different or the same with the same name and it
should still trigger MultipleChildElementsWithSameName. Actually I'm wondering
if we ougt to leave NamespaceDifferenceOnly alone since it's very clear that
it's for the case where the name is the same and the namespace is different,
and MultipleChildElementsWithSameName is for the case where the name is the
same regardless of whether the namespace is different or the same?
--
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]