stevedlawrence commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1050865552


##########
daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSetIncludesAndImportsMixins.scala:
##########
@@ -57,13 +57,20 @@ trait SchemaSetIncludesAndImportsMixin { self: SchemaSet =>
   lazy val allSchemaFiles = {
     val fd = fakeXMLSchemaDocument //bootstrap
     val sa = fd.seenAfter
+    val (_, first) = if (sa.value.isEmpty) (null, null) else sa.value.head
     val sfl = sa.value.flatMap {
       case (_, ii) => {
         val sf = ii.iiSchemaFileMaybe // maybe not if we've already seen this 
file for the same namespace.
+        // Require the first schema file to have a DFDL namespace. Other 
included or imported schemas can be
+        // standard XSD schemas but emit a warning that the schema is being 
ignored.
         sf.filter { f =>
-          if (f.isDFDLSchemaFile)
+          if (f.isDFDLSchemaFile) {
             true
-          else {
+          } else if (f eq first) {
+            f.SDEButContinue("Non-DFDL Schema file. Does not have DFDL 
namespace definition on schema root element.\n" +

Review Comment:
   Why `SDEButContinue` instead of `SDE`? Seems like we would want to 
immediately stop if the main schema isn't a DFDL schema.



##########
daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaSetIncludesAndImportsMixins.scala:
##########
@@ -57,13 +57,20 @@ trait SchemaSetIncludesAndImportsMixin { self: SchemaSet =>
   lazy val allSchemaFiles = {
     val fd = fakeXMLSchemaDocument //bootstrap
     val sa = fd.seenAfter
+    val (_, first) = if (sa.value.isEmpty) (null, null) else sa.value.head

Review Comment:
   Is it actually possible for `sa.value.isEmpty` to be true? Seems like we 
must always have at least one value since we must be compiling something. If 
so, could this be simplified to this:
   ```scala
   val first = sa.value.head._2
   ```
   Then we don't this `null` stuff, which we tend to avoid in scala.



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