You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/12/16 14:41:43 UTC

[GitHub] [daffodil] mike-mcgann opened a new pull request, #895: Require the first schema to include the DFDL namespace.

mike-mcgann opened a new pull request, #895:
URL: https://github.com/apache/daffodil/pull/895

   If a schema document is passed to Daffodil that does not contain a DFDL namespace, it is currently ignored and a warning is emitted. If this is the only document then no operation actually occurs and this condition can be masked when warnings are disabled. Enforce the first schema to include the DFDL namespace but emit warnings on subsequent imports or inclusions.
   
   [DAFFODIL-2441](https://issues.apache.org/jira/browse/DAFFODIL-2441)


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] mike-mcgann commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
mike-mcgann commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1050894755


##########
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:
   Updated with the recommended change. 



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] mike-mcgann commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
mike-mcgann commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1054493443


##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}
+
+object TestSchemaWithoutDFDLNamespace {
+  val testDir = "/org/apache/daffodil/section00/general/"
+  val runner = Runner(testDir, "testSchemaWithoutDFDLNamespace.tdml")
+
+  @AfterClass def shutDown(): Unit = {
+    runner.reset

Review Comment:
   I'm seeing them now. They were there but very subtle as you indicated. I'm brand new to Scala and IDEA so it may take me a bit to learn these. Thanks for the info. 
   
   I've updated the tests to include the recommended changes from the warnings. 



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] mike-mcgann commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
mike-mcgann commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1054493443


##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}
+
+object TestSchemaWithoutDFDLNamespace {
+  val testDir = "/org/apache/daffodil/section00/general/"
+  val runner = Runner(testDir, "testSchemaWithoutDFDLNamespace.tdml")
+
+  @AfterClass def shutDown(): Unit = {
+    runner.reset

Review Comment:
   I'm seeing them now. They were there but very subtle as you indicated. I'm brand new to Scala and IDEA so it take me a bit to learn these. Thanks for the info. 
   
   I've updated the tests to include the recommended changes from the warnings. 



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] tuxji commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
tuxji commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1052380048


##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}
+
+object TestSchemaWithoutDFDLNamespace {
+  val testDir = "/org/apache/daffodil/section00/general/"
+  val runner = Runner(testDir, "testSchemaWithoutDFDLNamespace.tdml")
+
+  @AfterClass def shutDown(): Unit = {
+    runner.reset

Review Comment:
   For future reference, we don't want new code to have easily fixable IDE warnings (val runner: Runner = ..., and runner.reset()).  IDEA even tries to prevent you from committing code with such warnings so other devs changing the same file will have to fix the warnings or answer yes, commit anyway.  Scala 3 migration will need these fixes anyway if my memory is correct.



##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}

Review Comment:
   You may want to check your IDE's settings (IDEA may have Editor/Code Style/Scala/Imports/Merge imports with the same prefix into one statement/ enabled by default).  Daffodil devs prefer imports to be on separate statements.



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] mike-mcgann commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
mike-mcgann commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1052490455


##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}

Review Comment:
   Imports have been updated. 



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] mike-mcgann commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
mike-mcgann commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1050894304


##########
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:
   Updated with the recommended change. 



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] mike-mcgann commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
mike-mcgann commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1052493478


##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}
+
+object TestSchemaWithoutDFDLNamespace {
+  val testDir = "/org/apache/daffodil/section00/general/"
+  val runner = Runner(testDir, "testSchemaWithoutDFDLNamespace.tdml")
+
+  @AfterClass def shutDown(): Unit = {
+    runner.reset

Review Comment:
   I'm not seeing any warnings over here. Can you let me know what the warnings are and I'll see if I can get those turned on. Thanks. 



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] tuxji commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
tuxji commented on code in PR #895:
URL: https://github.com/apache/daffodil/pull/895#discussion_r1053794811


##########
daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestSchemaWithoutDFDLNamespace.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.section00.general
+
+import org.apache.daffodil.tdml.Runner
+import org.junit.{AfterClass, Test}
+
+object TestSchemaWithoutDFDLNamespace {
+  val testDir = "/org/apache/daffodil/section00/general/"
+  val runner = Runner(testDir, "testSchemaWithoutDFDLNamespace.tdml")
+
+  @AfterClass def shutDown(): Unit = {
+    runner.reset

Review Comment:
   I'm not sure why you wouldn't see these warnings since IDEA should be enabling some kinds of warnings out of the box already.  You can check your IDEA settings: Open File -> Settings, type scala into the search box, hit the Enter key, and click on Editor -> Inspections to see all the enabled Scala warnings (Build -> Compiler -> Scala Compiler also has an Enable warnings setting which should be enabled too).  
   
   Another possibility is that you're not seeing the warnings because IDEA is very subtle in showing them (a yellow bar in the right gutter, a count of warnings in the upper right corner, and you have to click on the count to see a list of warnings in the Problems tab).



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] stevedlawrence merged pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
stevedlawrence merged PR #895:
URL: https://github.com/apache/daffodil/pull/895


-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [daffodil] stevedlawrence commented on a diff in pull request #895: Require the first schema to include the DFDL namespace.

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org