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

Fix Ignored RootNS #1367

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

olabusayoT
Copy link
Contributor

  • currently we find the root element using only the local name of an element, this can result in ambiguous roots and an error if you have an element with no namespace and one with a namespace. This PR fixes that by searching using the qname instead
  • add search for qname option if no namespace is specified, because there might still be an unambiguous root element within a namespace, the user just opted not to specify it

DAFFODIL-2947

- currently we find the root element using only the local name of an element, this can result in ambiguous roots and an error if you have an element with no namespace and one with a namespace. This PR fixes that by searching using the qname instead
- add search for qname option if no namespace is specified, because there might still be an unambiguous root element within a namespace, the user just opted not to specify it

DAFFODIL-2947
Copy link
Contributor

@mbeckerle mbeckerle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 minor suggestion for doc to add.

if (possibleRoots.length == 1) {
possibleRoots.head
} else {
val qn = RefQName(None, rootElementName, NoNamespace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments explaining the rationale here. E.g.,

It's ambiguous what root element, and no namespace URI was provided. 
So we assume not specifying a namespace URI may mean the intention 
was to choose the root that it is in No Namespace. 
If there is no such, then the diagnostic will encourage user to specify
the namespace explicitly. 

<tdml:testSuite suiteName="theSuiteName" xmlns:ex={example} xmlns:tdml={tdml} xmlns:dfdl={
dfdl
} xmlns:xsd={xsd} xmlns:xs={xsd} xmlns:xsi={xsi}>
<tdml:parserTestCase name="test1" root="data" rootNS="" model="/test/tdml/chameleon-schema1.dfdl.xsd">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename test to reflect that rootNS is being used to specify no namespace. It's not only multiple root candidates but that one of them is no namespace, and this illustrates how to specify that.

- add doc comment
- update test names

DAFFODIL-2947
- use Schemas.searchGlobalElementDecl instead of duplicating effort

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