Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema generation subcommand #45

Merged

Conversation

nikitawootten-nist
Copy link
Collaborator

@nikitawootten-nist nikitawootten-nist commented Jul 13, 2023

Committer Notes

Adds a subcommand and smoke tests for schema generation.

Also:

  • Remove duplicate README
  • Small script improvements

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you squashed any non-relevant commits and commit messages? [instructions]
  • Do all automated CI/CD checks pass?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you included examples of how to use your new feature(s)?
  • Have you updated all website and readme documentation affected by the changes you made? Changes to the website can be made in the website/content directory of your branch.

Copy link
Collaborator

@wendellpiez wendellpiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Looking forward to more of this.

Copy link
Contributor

@aj-stein-nist aj-stein-nist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I may be falling behind and/or reviewing these in the incorrect order, but trying this out and stubbing in a bash -x to see what's happening in the latter variant.

$ ./bin/metaschema-xslt schema-gen ~/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml "$tmp" oscal_catalog
$ ./bin/metaschema-xslt schema-gen ~/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml "$tmp" oscal_catalog
Unparseable command line argument: '/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl'.

XML Calabash version 1.5.3, an XProc processor.
Copyright (c) 2007-2019 Norman Walsh
See docs/notices/NOTICES in the distribution for licensing
See also http://xmlcalabash.com/ for more information

Usage: com.xmlcalabash.drivers.Main [switches/options] [pipeline.xpl] [options]
   or: com.xmlcalabash.drivers.Main [switches/options] { [inputs/parameters] step [options] }+

Where switches are:
  -a, --schema-aware                         Turn on schema-aware processing,
                                             this also sets saxon-processor to 'ee' implicitly
  -b, --binding prefix=uri                   Specify namespace binding
  -c, --config configfile                    Specify a particular configuration file
  -d, --data-input [contentType@][port=]uri  Bind the specified input port to data, if no port is specified,
                                             the first unbound input port is used
  -D, --debug                                Turn on debugging
  -E, --entity-resolver className            Specify a resolver class for entity resolution
  -G, --log-style logstyle                   Specify the default style for p:log output;
                                             Must be 'off', 'plain', 'wrapped' (default), or 'directory'
  -i, --input [port=]uri                     Bind the specified input port, if no port is specified,
                                             the first unbound input port is used
  -l, --library library.xpl                  Load the specified library
  -o, --output [port=]uri                    Bind the specified output port, if no port is specified,
                                             the first unbound output port is used
  -p, --with-param [port@]param=value        Specify a parameter
      --profile file                         Specify a file, or '-' for console output,
                                             where to write profiling information of the
                                             pipeline that was run
  -P, --saxon-processor edition              Request a specific edition of Saxon;
                                             Must be 'he' (default), 'pe' or 'ee'
  -s, --step stepname                        Run the step named 'stepname' instead of a pipeline
  -S, --safe-mode                            Request 'safe' execution
  -U, --uri-resolver className               Specify a resolver class for URI resolution
  -v, --version                              Show XML Calabash version
  -X, --extension extname                    Enable the 'extname' extension;
                                             valid extname values are 'general-values', 'xpointer-on-text',
                                             'transparent-json', 'json-flavor=<flavor>' and 'use-xslt-10'
      --saxon-configuration file             Load the specified Saxon configuration

For more information, consult http://xmlcalabash.com/docs/reference/ or
the documentation that came with the distribution.

I need to investigate further, but it seems the XProc invocation isn't going as planned. Are we testing this with updated versions of the XPL files locally from the adjacent WIP PRs?

$ ./bin/metaschema-xslt schema-gen ~/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml "$tmp" oscal_catalog
+++ dirname /home/me/code/metaschema-xslt/branches/nikita/command-schemas/bin/../src/schema-gen/mvn-schemas-xpl.sh
++ cd /home/me/code/metaschema-xslt/branches/nikita/command-schemas/bin/../src/schema-gen
++ pwd
+ SCRIPT_DIR=/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen
+ source /home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/../common/subcommand_common.bash
++ set -Eeuo pipefail
+++ command -v mvn
++ '[' -x /home/me/.asdf/shims/mvn ']'
++++ dirname /home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/../common/subcommand_common.bash
+++ cd /home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/../common
+++ pwd
++ _SUBCOMMAND_COMMON_DIR=/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/common
++ POM_FILE=/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/common/../../support/pom.xml
++ CALABASH_MAIN_CLASS=com.xmlcalabash.drivers.Main
++ SAXON_MAIN_CLASS=net.sf.saxon.Transform
++ unset -f _SUBCOMMAND_COMMON_DIR
+ [[ -z /home/me/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml ]]
+ METASCHEMA_XML=/home/me/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml
+ [[ -z /tmp/tmp.GApC6ERIxI ]]
+ SCHEMA_NAME=/tmp/tmp.GApC6ERIxI
++ shift 2
++ echo oscal_catalog
+ ADDITIONAL_ARGS=oscal_catalog
+ PIPELINE=/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl
+ XSD_FILE=/tmp/tmp.GApC6ERIxI_schema.xsd
+ JSONSCHEMA_FILE=/tmp/tmp.GApC6ERIxI_schema.json
+ CALABASH_ARGS='-i METASCHEMA="/home/me/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml"                -o INT_0_echo-input=/dev/null                -o INT_1_composed-metaschema=/dev/null                -o OUT_json-schema-xml=/dev/null                -o OUT_json-schema="/tmp/tmp.GApC6ERIxI_schema.json"                -o OUT_xml-schema="/tmp/tmp.GApC6ERIxI_schema.xsd"                oscal_catalog "/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl"'
++ dirname /tmp/tmp.GApC6ERIxI
+ mkdir -p /tmp
+ '[' -e /tmp/tmp.GApC6ERIxI_schema.xsd ']'
+ '[' -e /tmp/tmp.GApC6ERIxI_schema.json ']'
+ invoke_calabash '-i METASCHEMA="/home/me/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml"                -o INT_0_echo-input=/dev/null                -o INT_1_composed-metaschema=/dev/null                -o OUT_json-schema-xml=/dev/null                -o OUT_json-schema="/tmp/tmp.GApC6ERIxI_schema.json"                -o OUT_xml-schema="/tmp/tmp.GApC6ERIxI_schema.xsd"                oscal_catalog "/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl"'
+ exec_maven com.xmlcalabash.drivers.Main '-i METASCHEMA="/home/me/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml"                -o INT_0_echo-input=/dev/null                -o INT_1_composed-metaschema=/dev/null                -o OUT_json-schema-xml=/dev/null                -o OUT_json-schema="/tmp/tmp.GApC6ERIxI_schema.json"                -o OUT_xml-schema="/tmp/tmp.GApC6ERIxI_schema.xsd"                oscal_catalog "/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl"'
+ mvn --quiet -f /home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/common/../../support/pom.xml exec:java -Dexec.mainClass=com.xmlcalabash.drivers.Main '-Dexec.args=-i METASCHEMA="/home/me/code/oscal/branches/origin/develop/src/metaschema/oscal_catalog_metaschema.xml"                -o INT_0_echo-input=/dev/null                -o INT_1_composed-metaschema=/dev/null                -o OUT_json-schema-xml=/dev/null                -o OUT_json-schema="/tmp/tmp.GApC6ERIxI_schema.json"                -o OUT_xml-schema="/tmp/tmp.GApC6ERIxI_schema.xsd"                oscal_catalog "/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl"'
Unparseable command line argument: '/home/me/code/metaschema-xslt/branches/nikita/command-schemas/src/schema-gen/METASCHEMA-ALL-SCHEMAS.xpl'.

XML Calabash version 1.5.3, an XProc processor.
Copyright (c) 2007-2019 Norman Walsh
See docs/notices/NOTICES in the distribution for licensing
See also http://xmlcalabash.com/ for more information

Usage: com.xmlcalabash.drivers.Main [switches/options] [pipeline.xpl] [options]
   or: com.xmlcalabash.drivers.Main [switches/options] { [inputs/parameters] step [options] }+

Where switches are:
  -a, --schema-aware                         Turn on schema-aware processing,
                                             this also sets saxon-processor to 'ee' implicitly
  -b, --binding prefix=uri                   Specify namespace binding
  -c, --config configfile                    Specify a particular configuration file
  -d, --data-input [contentType@][port=]uri  Bind the specified input port to data, if no port is specified,
                                             the first unbound input port is used
  -D, --debug                                Turn on debugging
  -E, --entity-resolver className            Specify a resolver class for entity resolution
  -G, --log-style logstyle                   Specify the default style for p:log output;
                                             Must be 'off', 'plain', 'wrapped' (default), or 'directory'
  -i, --input [port=]uri                     Bind the specified input port, if no port is specified,
                                             the first unbound input port is used
  -l, --library library.xpl                  Load the specified library
  -o, --output [port=]uri                    Bind the specified output port, if no port is specified,
                                             the first unbound output port is used
  -p, --with-param [port@]param=value        Specify a parameter
      --profile file                         Specify a file, or '-' for console output,
                                             where to write profiling information of the
                                             pipeline that was run
  -P, --saxon-processor edition              Request a specific edition of Saxon;
                                             Must be 'he' (default), 'pe' or 'ee'
  -s, --step stepname                        Run the step named 'stepname' instead of a pipeline
  -S, --safe-mode                            Request 'safe' execution
  -U, --uri-resolver className               Specify a resolver class for URI resolution
  -v, --version                              Show XML Calabash version
  -X, --extension extname                    Enable the 'extname' extension;
                                             valid extname values are 'general-values', 'xpointer-on-text',
                                             'transparent-json', 'json-flavor=<flavor>' and 'use-xslt-10'
      --saxon-configuration file             Load the specified Saxon configuration

For more information, consult http://xmlcalabash.com/docs/reference/ or
the documentation that came with the distribution.

@nikitawootten-nist
Copy link
Collaborator Author

Hey AJ, whoops looks like I changed the usage without changing the arguments. Let me fix that. Good catch!

@nikitawootten-nist nikitawootten-nist merged commit 1c409ac into usnistgov:develop Jul 14, 2023
@nikitawootten-nist nikitawootten-nist deleted the command-schemas branch July 14, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants