stevedlawrence commented on code in PR #183:
URL: https://github.com/apache/daffodil-sbt/pull/183#discussion_r3288841123


##########
README.md:
##########
@@ -323,6 +323,87 @@ root `src/` directory, and all test source and resource 
files to be in a root
 `test/` directory. Source files are those that end with `*.scala` or `*.java`,
 and resource files are anything else.
 
+### Flatten Schemas
+
+Many non-Daffodil XML/XSD programs (such as XML validators) do not resolve
+schemaLocation's in the same way that Daffodil does and will often stuggle to
+find schemas that aren't in the same directory as the root schema. By 
flattening
+the directory structure at a common root (ie the directory containing 'com/'
+and/or 'org/' we can rename all of the schemas while avoiding any conflicts in
+schema name for generically named schemas, like 'baseFormat.dfdl.xsd'. Having
+all of the schemas and schemaLocation's renamed should allow tools with less
+robust schemaLocation resolvers to just work.
+
+This plugin has functionality to flatten the directory structure of 1 or more
+schema projects, renaming the schema files and upating schemaLocation's as
+necessary.
+
+```bash
+sbt daffodilFlattenSchemas
+```
+
+The renaming works as follows:
+
+`org/apache/daffodil/xsd/main.dfdl.xsd`
+
+will be renamed to:
+
+`org__apache__daffodil__xsd__main.dfdl.xsd`
+
+Note: Original files are not modified, they are simply copied to the specified
+output directory with the new name and updated schemaLocation's.
+
+#### Flatten Schemas Settings
+
+
+##### daffodilFlattenSchemasTarget
+
+Sets the target path for outputting the flattened schema zip file.
+
+Defaults to:
+```scala
+daffodilFlattenSchemasTarget := target.value / 
s"${name.value}-${version.value}-flat.zip"
+```
+
+##### daffodilFlattenSchemasReferencePatterns
+
+Defines the regular expression patterns used for matching references in schema
+documents.  The regular expressions must define a capture group to the 
reference
+string.
+
+Defaults to:
+```scala
+daffodilFlattenResourceReferencePatterns := List(
+  """(?<!xsi:)schemaLocation=\"([^\"]*)\"""".r,
+  "href=\"([^\"]*)\"".r,
+  "document[(]'([^']*)'[)]".r
+)
+```
+
+##### daffodilFlattenSchemas / includeFilter
+
+Defines a filter for detecting which files from the current project should be
+included in the flattened schema package. Note that this setting only effects
+files in the current project. Files from the current projects dependencies will
+be added if they are referenced by the current project's schema files.
+
+Defaults to:
+```scala
+daffodilFlattenSchemas / includeFilter := "*.xsd" | "*.xsl" | "*.xslt" | 
"*.xml"
+```
+
+##### daffodilFlattenSchemas / excludeFilter
+
+Defines a filter for which files to exclude from the flattened schema package.
+Again this setting only effects files from the current project. It will not
+effect files from dependencies of the current project.
+
+Defaults to:
+```scala
+daffodilFlattenSchemas / excludeFilter := HiddenFileFilter
+```
+
+Sets

Review Comment:
   Remove "Sets"



##########
README.md:
##########
@@ -323,6 +323,87 @@ root `src/` directory, and all test source and resource 
files to be in a root
 `test/` directory. Source files are those that end with `*.scala` or `*.java`,
 and resource files are anything else.
 
+### Flatten Schemas
+
+Many non-Daffodil XML/XSD programs (such as XML validators) do not resolve
+schemaLocation's in the same way that Daffodil does and will often stuggle to
+find schemas that aren't in the same directory as the root schema. By 
flattening
+the directory structure at a common root (ie the directory containing 'com/'
+and/or 'org/' we can rename all of the schemas while avoiding any conflicts in
+schema name for generically named schemas, like 'baseFormat.dfdl.xsd'. Having
+all of the schemas and schemaLocation's renamed should allow tools with less
+robust schemaLocation resolvers to just work.
+
+This plugin has functionality to flatten the directory structure of 1 or more
+schema projects, renaming the schema files and upating schemaLocation's as
+necessary.
+
+```bash
+sbt daffodilFlattenSchemas
+```
+
+The renaming works as follows:
+
+`org/apache/daffodil/xsd/main.dfdl.xsd`
+
+will be renamed to:
+
+`org__apache__daffodil__xsd__main.dfdl.xsd`
+
+Note: Original files are not modified, they are simply copied to the specified
+output directory with the new name and updated schemaLocation's.
+
+#### Flatten Schemas Settings
+
+
+##### daffodilFlattenSchemasTarget
+
+Sets the target path for outputting the flattened schema zip file.
+
+Defaults to:
+```scala
+daffodilFlattenSchemasTarget := target.value / 
s"${name.value}-${version.value}-flat.zip"
+```

Review Comment:
   I think code examples are useful for things that are strictly code, or when 
giving examples on how to change from the defaults, but I usually prefer for 
explanations of defaults to be more human readable. That way you don't need to 
be a scala/sbt expert to know how things work if you don't change anything. For 
example, maybe something like:
   
   The default location is `<name>-<version>-flat.zip` in the `target/` 
directory.



##########
README.md:
##########
@@ -323,6 +323,87 @@ root `src/` directory, and all test source and resource 
files to be in a root
 `test/` directory. Source files are those that end with `*.scala` or `*.java`,
 and resource files are anything else.
 
+### Flatten Schemas
+
+Many non-Daffodil XML/XSD programs (such as XML validators) do not resolve
+schemaLocation's in the same way that Daffodil does and will often stuggle to
+find schemas that aren't in the same directory as the root schema. By 
flattening
+the directory structure at a common root (ie the directory containing 'com/'
+and/or 'org/' we can rename all of the schemas while avoiding any conflicts in
+schema name for generically named schemas, like 'baseFormat.dfdl.xsd'. Having
+all of the schemas and schemaLocation's renamed should allow tools with less
+robust schemaLocation resolvers to just work.
+
+This plugin has functionality to flatten the directory structure of 1 or more
+schema projects, renaming the schema files and upating schemaLocation's as
+necessary.
+
+```bash
+sbt daffodilFlattenSchemas
+```
+
+The renaming works as follows:
+
+`org/apache/daffodil/xsd/main.dfdl.xsd`
+
+will be renamed to:
+
+`org__apache__daffodil__xsd__main.dfdl.xsd`
+
+Note: Original files are not modified, they are simply copied to the specified
+output directory with the new name and updated schemaLocation's.
+
+#### Flatten Schemas Settings
+
+
+##### daffodilFlattenSchemasTarget
+
+Sets the target path for outputting the flattened schema zip file.
+
+Defaults to:
+```scala
+daffodilFlattenSchemasTarget := target.value / 
s"${name.value}-${version.value}-flat.zip"
+```
+
+##### daffodilFlattenSchemasReferencePatterns
+
+Defines the regular expression patterns used for matching references in schema
+documents.  The regular expressions must define a capture group to the 
reference
+string.
+
+Defaults to:
+```scala
+daffodilFlattenResourceReferencePatterns := List(
+  """(?<!xsi:)schemaLocation=\"([^\"]*)\"""".r,
+  "href=\"([^\"]*)\"".r,
+  "document[(]'([^']*)'[)]".r
+)
+```
+
+##### daffodilFlattenSchemas / includeFilter
+
+Defines a filter for detecting which files from the current project should be

Review Comment:
   Maybe add "which files in the resource directories of the current project" 
to make it clear it won't match any source files.



##########
README.md:
##########
@@ -323,6 +323,87 @@ root `src/` directory, and all test source and resource 
files to be in a root
 `test/` directory. Source files are those that end with `*.scala` or `*.java`,
 and resource files are anything else.
 
+### Flatten Schemas
+
+Many non-Daffodil XML/XSD programs (such as XML validators) do not resolve
+schemaLocation's in the same way that Daffodil does and will often stuggle to
+find schemas that aren't in the same directory as the root schema. By 
flattening
+the directory structure at a common root (ie the directory containing 'com/'
+and/or 'org/' we can rename all of the schemas while avoiding any conflicts in
+schema name for generically named schemas, like 'baseFormat.dfdl.xsd'. Having
+all of the schemas and schemaLocation's renamed should allow tools with less
+robust schemaLocation resolvers to just work.
+
+This plugin has functionality to flatten the directory structure of 1 or more
+schema projects, renaming the schema files and upating schemaLocation's as
+necessary.
+
+```bash
+sbt daffodilFlattenSchemas
+```
+
+The renaming works as follows:
+
+`org/apache/daffodil/xsd/main.dfdl.xsd`
+
+will be renamed to:
+
+`org__apache__daffodil__xsd__main.dfdl.xsd`
+
+Note: Original files are not modified, they are simply copied to the specified
+output directory with the new name and updated schemaLocation's.
+
+#### Flatten Schemas Settings
+
+
+##### daffodilFlattenSchemasTarget
+
+Sets the target path for outputting the flattened schema zip file.
+
+Defaults to:
+```scala
+daffodilFlattenSchemasTarget := target.value / 
s"${name.value}-${version.value}-flat.zip"
+```
+
+##### daffodilFlattenSchemasReferencePatterns
+
+Defines the regular expression patterns used for matching references in schema
+documents.  The regular expressions must define a capture group to the 
reference
+string.
+
+Defaults to:
+```scala
+daffodilFlattenResourceReferencePatterns := List(
+  """(?<!xsi:)schemaLocation=\"([^\"]*)\"""".r,
+  "href=\"([^\"]*)\"".r,
+  "document[(]'([^']*)'[)]".r
+)

Review Comment:
   Simlar to above, maybe say something like:
   
   Supports XSD include/import `schemaLocation`, and XSLT `href`/`document` 
attributes.
   
   This way you don't have to be a regex expert to understand what we support 
by default.



##########
src/main/scala/org/apache/daffodil/DaffodilPlugin.scala:
##########
@@ -950,7 +1214,9 @@ object DaffodilPlugin extends AutoPlugin {
         publish := {},
         publishLocal := {},
         publishM2 := {},
-        publish / skip := true
+        publish / skip := true,
+        daffodilFlattenSchemas / products := Seq(),

Review Comment:
   Can you add a comment here to say that only the root project creates or 
publishes flattened schemas? Makes it clear that these lines aren't related to 
disabling publishing for supprojects like the above comment talks about.



##########
README.md:
##########
@@ -323,6 +323,87 @@ root `src/` directory, and all test source and resource 
files to be in a root
 `test/` directory. Source files are those that end with `*.scala` or `*.java`,
 and resource files are anything else.
 
+### Flatten Schemas
+
+Many non-Daffodil XML/XSD programs (such as XML validators) do not resolve
+schemaLocation's in the same way that Daffodil does and will often stuggle to
+find schemas that aren't in the same directory as the root schema. By 
flattening
+the directory structure at a common root (ie the directory containing 'com/'
+and/or 'org/' we can rename all of the schemas while avoiding any conflicts in
+schema name for generically named schemas, like 'baseFormat.dfdl.xsd'. Having
+all of the schemas and schemaLocation's renamed should allow tools with less
+robust schemaLocation resolvers to just work.
+
+This plugin has functionality to flatten the directory structure of 1 or more
+schema projects, renaming the schema files and upating schemaLocation's as
+necessary.
+
+```bash
+sbt daffodilFlattenSchemas
+```
+
+The renaming works as follows:
+
+`org/apache/daffodil/xsd/main.dfdl.xsd`
+
+will be renamed to:
+
+`org__apache__daffodil__xsd__main.dfdl.xsd`
+
+Note: Original files are not modified, they are simply copied to the specified
+output directory with the new name and updated schemaLocation's.
+
+#### Flatten Schemas Settings
+
+
+##### daffodilFlattenSchemasTarget
+
+Sets the target path for outputting the flattened schema zip file.
+
+Defaults to:
+```scala
+daffodilFlattenSchemasTarget := target.value / 
s"${name.value}-${version.value}-flat.zip"
+```
+
+##### daffodilFlattenSchemasReferencePatterns
+
+Defines the regular expression patterns used for matching references in schema
+documents.  The regular expressions must define a capture group to the 
reference
+string.
+
+Defaults to:
+```scala
+daffodilFlattenResourceReferencePatterns := List(
+  """(?<!xsi:)schemaLocation=\"([^\"]*)\"""".r,
+  "href=\"([^\"]*)\"".r,
+  "document[(]'([^']*)'[)]".r
+)
+```
+
+##### daffodilFlattenSchemas / includeFilter
+
+Defines a filter for detecting which files from the current project should be
+included in the flattened schema package. Note that this setting only effects
+files in the current project. Files from the current projects dependencies will
+be added if they are referenced by the current project's schema files.
+
+Defaults to:
+```scala
+daffodilFlattenSchemas / includeFilter := "*.xsd" | "*.xsl" | "*.xslt" | 
"*.xml"
+```
+
+##### daffodilFlattenSchemas / excludeFilter
+
+Defines a filter for which files to exclude from the flattened schema package.
+Again this setting only effects files from the current project. It will not
+effect files from dependencies of the current project.
+
+Defaults to:
+```scala
+daffodilFlattenSchemas / excludeFilter := HiddenFileFilter

Review Comment:
   And just say hidden files/directories are excluded by default.



##########
README.md:
##########
@@ -323,6 +323,87 @@ root `src/` directory, and all test source and resource 
files to be in a root
 `test/` directory. Source files are those that end with `*.scala` or `*.java`,
 and resource files are anything else.
 
+### Flatten Schemas
+
+Many non-Daffodil XML/XSD programs (such as XML validators) do not resolve
+schemaLocation's in the same way that Daffodil does and will often stuggle to
+find schemas that aren't in the same directory as the root schema. By 
flattening
+the directory structure at a common root (ie the directory containing 'com/'
+and/or 'org/' we can rename all of the schemas while avoiding any conflicts in
+schema name for generically named schemas, like 'baseFormat.dfdl.xsd'. Having
+all of the schemas and schemaLocation's renamed should allow tools with less
+robust schemaLocation resolvers to just work.
+
+This plugin has functionality to flatten the directory structure of 1 or more
+schema projects, renaming the schema files and upating schemaLocation's as
+necessary.
+
+```bash
+sbt daffodilFlattenSchemas
+```
+
+The renaming works as follows:
+
+`org/apache/daffodil/xsd/main.dfdl.xsd`
+
+will be renamed to:
+
+`org__apache__daffodil__xsd__main.dfdl.xsd`
+
+Note: Original files are not modified, they are simply copied to the specified
+output directory with the new name and updated schemaLocation's.
+
+#### Flatten Schemas Settings
+
+
+##### daffodilFlattenSchemasTarget
+
+Sets the target path for outputting the flattened schema zip file.
+
+Defaults to:
+```scala
+daffodilFlattenSchemasTarget := target.value / 
s"${name.value}-${version.value}-flat.zip"
+```
+
+##### daffodilFlattenSchemasReferencePatterns
+
+Defines the regular expression patterns used for matching references in schema
+documents.  The regular expressions must define a capture group to the 
reference
+string.
+
+Defaults to:
+```scala
+daffodilFlattenResourceReferencePatterns := List(
+  """(?<!xsi:)schemaLocation=\"([^\"]*)\"""".r,
+  "href=\"([^\"]*)\"".r,
+  "document[(]'([^']*)'[)]".r
+)
+```
+
+##### daffodilFlattenSchemas / includeFilter
+
+Defines a filter for detecting which files from the current project should be
+included in the flattened schema package. Note that this setting only effects
+files in the current project. Files from the current projects dependencies will
+be added if they are referenced by the current project's schema files.
+
+Defaults to:
+```scala
+daffodilFlattenSchemas / includeFilter := "*.xsd" | "*.xsl" | "*.xslt" | 
"*.xml"

Review Comment:
   Similarly, just say "By default, only files with the following extensions 
are included: ...".



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