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


##########
daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner2.scala:
##########
@@ -608,4 +608,80 @@ abc # a comment
   @Test def test_apos_test1(): Unit = { runner.runOneTest("apos_test1") }
   @Test def test_apos_test2(): Unit = { runner.runOneTest("apos_test2") }
 
+  // DFDL-2947
+  @Test def test_multipleRootCandidates1(): Unit = {
+    val tdmlTestSuite =
+      <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">

Review Comment:
   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. 



##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaSet.scala:
##########
@@ -356,7 +356,15 @@ final class SchemaSet private (
         ge
       }
       case RootSpec(None, rootElementName) => {
-        findRootElement(rootElementName)
+        val possibleRoots: Seq[GlobalElementDecl] = schemaSet.schemas.flatMap {
+          _.schemaDocuments.flatMap(_.searchGlobalElementDecl(rootElementName))
+        }
+        if (possibleRoots.length == 1) {
+          possibleRoots.head
+        } else {
+          val qn = RefQName(None, rootElementName, NoNamespace)

Review Comment:
   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. 
   ```



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