Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olabusayoT
Copy link
Contributor

  • 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

- 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]] = {
Copy link
Member

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
Copy link
Member

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,
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants