mbeckerle commented on a change in pull request #49: Daffodil 1907 non dfdl 
annotation
URL: https://github.com/apache/incubator-daffodil/pull/49#discussion_r171312617
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/dsom/SchemaDocument.scala
 ##########
 @@ -124,6 +125,46 @@ final class XMLSchemaDocument(xmlArg: Node,
     res
   }.value
 
+  /**
+   *  True if root xs:schema element has an xmlns that uses the DFDL URI.
+   *
+   *  This could be a prefix definition (Most likely xmlns:dfdl='...' but could
+   *  be some other prefix.)
+   *
+   *  Or very very unlikely, it could be the default namespace.
+   */
+  private def hasDFDLNamespaceDefinition: Boolean = {
+    val scope = xml.scope
+    val pre = scope.getPrefix(XMLUtils.DFDL_NAMESPACE)
+    val hasSomePrefixForDFDLNamespace = pre ne null
+    val res = hasSomePrefixForDFDLNamespace ||
+      {
+        val default = scope.getURI(null)
+        val hasDefaultNamespaceAsDFDLNamespace = default == 
XMLUtils.DFDL_NAMESPACE.toString
+        hasDefaultNamespaceAsDFDLNamespace
+      }
+    res
+  }
+
+  /**
+   * True if this is a DFDL schema that Daffodil should process.
+   * False if this schema should be ignored because it has no DFDL annotations.
+   *
+   * We will ignore this import/include if it does not use the DFDL namespace
+   * definition for a prefix (or the default) on the xs:schema element.
+   *
+   * We do this so that other annotation languages can co-exist with DFDL.
+   * That is, they can use all of XML Schema including things DFDL doesn't 
allow
+   * like attribute decls, but only when those schemas are only needed
+   * to process non-DFDL annotations. Since Daffodil ignores non-DFDL 
annotations
+   * entirely, Daffodil won't run into these non-DFDL allowed things like
+   * attribute decls. But validators like Xerces will see the regular
+   * import/include and process normally, which enables validation of
+   * all annotations, DFDL and otherwise.
+   *
+   * Fixes DAFFODIL-1909
 
 Review comment:
   While I agree with you generally, this issue is such a subtle one that I 
thought it worthwhile to direct a programmer to read the bug ticket before 
messing further with this code. However I will change the phrasing so this 
looks less like some sort of advocated practice.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to