stevedlawrence commented on code in PR #183:
URL: https://github.com/apache/daffodil-sbt/pull/183#discussion_r3236231055
##########
src/main/scala/org/apache/daffodil/DaffodilPlugin.scala:
##########
@@ -840,6 +854,179 @@ object DaffodilPlugin extends AutoPlugin {
}
}
+ def daffodilFlattenSettings: Seq[Setting[_]] = Seq(
+ daffodilFlattenTarget := target.value /
s"${name.value}-${version.value}-flat.zip",
+
+ /**
+ * Whether or not to publish the flattened schemas zip. Defaults to false.
+ *
+ * If projects want to publish flattened schemas then they must explicitly
enable it by
+ * setting 'daffodilFlattenSchemas / publishArtifact := true'.
+ *
+ * If false, flattened schemas will not be created unless you explicitly
run the
+ * daffodilFlattenSchemas.
+ */
+ daffodilFlattenSchemas / publishArtifact := false,
+
+ daffodilFlattenSchemas / artifact := Artifact(
+ name.value,
+ "flat",
+ "zip",
+ Some("flat"),
+ Vector(),
+ None
+ ),
+
+ /**
+ * Only grab the file types that need to be flattened. These files are only
+ * grabbed from the root project. Any referenced files will be pulled in
+ * from the classpath. Note that XML files are commonly used in XSLT for
+ * settings.
+ */
+ daffodilFlattenSchemas / includeFilter := "*.xsd" | "*.xsl" | "*.xslt" |
"*.xml",
+ daffodilFlattenSchemas / excludeFilter := HiddenFileFilter,
+
+ daffodilFlattenResourceReferencePatterns := List(
+ """schemaLocation=\"([^\"]*)\"""".r,
Review Comment:
Reading the XSD spec about xsi:schemaLocation, I think the link16 schema
might be using it incorrectly. From the spec:
https://www.w3.org/TR/xmlschema-1/#xsi_schemaLocation
> The xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes can be
used in a document to provide hints as to the physical location of schema
documents which may be used for
[·assessment·](https://www.w3.org/TR/xmlschema-1/#key-va).
So xsi:schemaLocation is just a hint that can be used by XML parsers to know
where to find a schema that can be used to validate that XML. I think the
intent is that if you have a random bit of XML and you don't know which schema
to use to validate it you can use this attribute as a hint.
So by having this in our link16 schemas:
```xml
<schema ...
xsi:schemaLocation="urn:mil-std-6016f1-messages-DFDL
/com/owlcyberdefense/mil-std-6016f1/xsd/link16.main.gen.dfdl.xsd">
```
we are hinting that the link16 DFDL schema (not the infosets it creates)
should be validated using the link16.main.gen.dfdl.xsd schema. Which isn't
correct--DFDL schemas should validated using the XMLShema_for_DFDL.xsd.
Fortunately, I imagine most things just ignore this since they are told
exactly which schema to use for validation, especially in the case of
DFDL/Daffodil which has it's own logic for validating DFDL schemas.
And I found this in Daffodil that confirms that we do ignore this attribute:
https://github.com/apache/daffodil/blob/main/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaDocument.scala#L98-L99
So since Daffodil ignores it, and our values of it are wrong and probably
ignored by validators, I think should be safe to exclude it from flattening.
--
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]