-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn about Multiple Child Elements with Same Name #1321
base: main
Are you sure you want to change the base?
Warn about Multiple Child Elements with Same Name #1321
Conversation
- update code to reuse logic for unordered sequences check - add multipleChildElementsWithSameName warning - add test to check we get UPA error with choices - add tests to exercise new warning DAFFODIL-2736
) | ||
} | ||
|
||
private lazy val checkMembersHaveUniqueNamesInNamespaces: Map[Boolean, Seq[Term]] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might suggest a different name for this since it isn't really checking anything, it's just grouping things.
|
||
private lazy val checkIfMultipleChildrenWithSameName: Unit = { | ||
val nonUniqueNameChildren = | ||
checkMembersHaveUniqueNamesInNamespaces.filter(_._1 == true).values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this needs a different grouping than with the unorderd sequences?
The goal of this check is to warn in case the schema is used with an infoset that don't support duplicate fields, and those kinds of infosets probably also don't support namespaces. So we probably want to warn even if they have different namespaces, which means we need to group by name only and not by QName.
Also, we kindof already have a similar check with WarnID.NamespaceDifferencesOnly
. I wonder if that check should be removed in place of this one, since this new check is really just a more general version of that check? The existing one is about same-name elements next to each other, this one is about same-name elements that are siblings. Anything that this new check warns about will also warn for the existing check.
checkMembersHaveUniqueNamesInNamespaces.filter(_._1 == true).values | ||
nonUniqueNameChildren.foreach { children => | ||
children.head.SDW( | ||
WarnID.MultipleChildElementsWithSameName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this wants to be WarnID.NamespaceDifferencesOnly?
DAFFODIL-2736