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

Support sequences of objects of different types #228

Closed
5 tasks
david-waltermire opened this issue Aug 22, 2022 · 2 comments · Fixed by #470
Closed
5 tasks

Support sequences of objects of different types #228

david-waltermire opened this issue Aug 22, 2022 · 2 comments · Fixed by #470
Assignees
Labels
enhancement New feature or request

Comments

@david-waltermire
Copy link
Collaborator

User Story:

As a Metaschema model maintainer, I need a way to allow sequenced collections of objects of different types.

This could be accomplished using a syntax similar to the following.

<choice min-occurs="1" max-occurs="unbounded">
    <group-as name="tests" in-json="ARRAY"/>
    <discriminator in-json="object-type"/>
    <assembly ref="rule-condition">
        <use-name>condition</use-name>
        <discriminator-value>condition</discriminator-value>
    </assembly>
    <assembly ref="test-reference">
        <discriminator-value>test-reference</discriminator-value>
    </assembly>
    <field ref="testing-scenario-reference">
        <discriminator-value>testing-scenario</discriminator-value>
    </field>
</choice>

A JSON could look like the following.

{
    "tests": [
      {
        "object-type": "condition",
      },
      {
        "object-type": "test-reference"
      },
      {
        "object-type": "condition",
      },
      {
        "object-type": "testing-scenario"
      }
    ]
}

While the XML would look like:

<condition .../>
<test-reference .../>
<condition .../>
<testing-scenario-reference .../>

Goals:

  • define the Metaschema syntax for this
  • create follow-on issues to implement this in the XSLT and Java codebases

Dependencies:

None.

Acceptance Criteria

  • All website and readme documentation affected by the changes in this issue have been updated. Changes to the website can be made in the docs/content directory of your branch.
  • A Pull Request (PR) is submitted that fully addresses the goals of this User Story. This issue is referenced in the PR.
  • The CI-CD build process runs without any reported errors on the PR. This can be confirmed by reviewing that all checks have passed in the PR.
@david-waltermire david-waltermire added the enhancement New feature or request label Aug 22, 2022
@david-waltermire david-waltermire self-assigned this Aug 22, 2022
@wendellpiez
Copy link
Collaborator

I would very much welcome any ideas, concepts or leads on how to validate this in JSON and YAML, maybe whether JSON-LD or some similar extension provides a validation model especially one that is robust and well-liked.

FWIW in XML DTD or RNC syntax the mixed sequence pattern here is written as (a | b | c)* or (a | b | c)+ whereas current Metaschema supports only (a | b | c) (a choice, but only one), a+, b+ or a*, b* etc. (multiples, but not mixed).

One way to validate a mixed sequence is to cast all the object-type properties on children in sequence (array members in order) to a string, and match that against a regular expression representing (written as a cast from) the model. This is ugly but I have seen it work. Terrible error messages come back (not very useful even if you understand them). I am also skeptical that deploying such a test would be easily done in JSON Schema. Translating the model into bottom-up tests at the node level is a more attractive idea - is there a JSON Schema way to enforce a property value (here, object-type) be one of an enumeration, on any given array member (i.e. member of tests)? The metaschema constraint layer may also give us another place to intervene with testing, providing we get a parse.

FWIW this is much easier if we do not have to support a*, (b | c | d)*, e*, i.e. mixed sequences within ordered sequences (something that DTD, RNG and XSD all support for XML).

Suggest #object-type or some other prefixed name to keep clear of names of flags (arbitrarily-named properties defined by the metaschema) on these objects.

@wendellpiez
Copy link
Collaborator

Question also: how about when the tests objects has flags, ordinarily represented as properties?

XML:

<tests startdate="xxxx" enddate="yyyyy">
   <condition .../>
   <test-reference .../>
   <condition .../>
   <testing-scenario-reference .../>
</tests>

JSON?

david-waltermire added a commit to david-waltermire/metaschema-java-old that referenced this issue Dec 7, 2022
… simple and complex type generation.

Adjusted AutoCloser implementation, renaming methods to be more sensible.
Adjusted assembly model containers to better expose choice instances. This will help in the future when adding support for usnistgov/metaschema#228.
david-waltermire added a commit to david-waltermire/metaschema-java-old that referenced this issue Dec 7, 2022
… simple and complex type generation.

Adjusted AutoCloser implementation, renaming methods to be more sensible.
Adjusted assembly model containers to better expose choice instances. This will help in the future when adding support for usnistgov/metaschema#228.
david-waltermire added a commit to david-waltermire/metaschema-java-old that referenced this issue Dec 12, 2022
XML schema generation changes:
- Added support for inclusion of allowed values in XML schema as enumerations.
- Reorganized XML schema generation to provide for greater control over simple and complex type generation.
- Fixed bug causing unwrapped fields to not be generated properly.

JSON schema generation changes:
- Added support for inclusion of allowed values in JSON schema as enumerations.
- Refactored property generation to use a new property class hierarchy, which now encapsulates generation methods with their Metaschema constructs (i.e. flags, fields, assemblies).
- Completed refactor of JSON Schema object schema generation for Metaschema definitions and data types.
- Fixed ConcurrentModificationException caused by lazy schema initialization.

Model changes:
- Adjusted AutoCloser implementation, renaming methods to be more sensible.
- Adjusted assembly model containers to better expose choice instances. This will help in the future when adding support for usnistgov/metaschema#228.
- Improved error handling for Metapath compile errors to indicate the Metaschema the error occured in.

Code reorganization and method naming cleanup.
Cleaned up code, removing unused methods, imports, etc.
Fixed compile, PMD, and Spotbugs warnings.
Adopted latest metaschema commit
Updated GHA plugins to latest
Refactored and removed unneeded methods in both XML and JSON Schema generation.
david-waltermire added a commit to usnistgov/metaschema-java that referenced this issue Dec 12, 2022
XML schema generation changes:
- Added support for inclusion of allowed values in XML schema as enumerations.
- Reorganized XML schema generation to provide for greater control over simple and complex type generation.
- Fixed bug causing unwrapped fields to not be generated properly.

JSON schema generation changes:
- Added support for inclusion of allowed values in JSON schema as enumerations.
- Refactored property generation to use a new property class hierarchy, which now encapsulates generation methods with their Metaschema constructs (i.e. flags, fields, assemblies).
- Completed refactor of JSON Schema object schema generation for Metaschema definitions and data types.
- Fixed ConcurrentModificationException caused by lazy schema initialization.

Model changes:
- Adjusted AutoCloser implementation, renaming methods to be more sensible.
- Adjusted assembly model containers to better expose choice instances. This will help in the future when adding support for usnistgov/metaschema#228.
- Improved error handling for Metapath compile errors to indicate the Metaschema the error occured in.

Code reorganization and method naming cleanup.
Cleaned up code, removing unused methods, imports, etc.
Fixed compile, PMD, and Spotbugs warnings.
Adopted latest metaschema commit
Updated GHA plugins to latest
Refactored and removed unneeded methods in both XML and JSON Schema generation.
david-waltermire added a commit that referenced this issue Oct 27, 2023
…228.

Fixed some minor content defects.
Added a draft Metaschema Metaschema in schema/metaschema/metaschema-metaschema.xml.
david-waltermire added a commit to usnistgov/metaschema-java that referenced this issue Oct 28, 2023
…ests around parsing a Metaschema Metaschema. The full metaschema won't be parsed until a solution to usnistgov/metaschema#228 is implemented.

Added a new databind-metaschema/pom.xml Maven module as a placeholder for new parsing code based on generated Metaschema classes.
david-waltermire added a commit to usnistgov/metaschema-java that referenced this issue Nov 9, 2023
* Added a bunch of Javadoc comments.
Added support for flag and field instances to provide a different default value than the definition.
Implemented experimental support for let statements in constraints.
Refactored constraint parsing in the databind module.
Removed some unused code.

* Fixed maven warning caused by duplicate plugin declaration in pluginManagement.
Completed support for default value support on instances.

* Unified external constraint processing through use of an ExternalConstraintsModulePostProcessor.
Completed initial support for the MetaConstraintLoader. Still need to implement a true Metaschema-based Metaschema model to get constraint scope targeting working correctly.

* Added the start of a Metaschema Metaschema implementation by adding tests around parsing a Metaschema Metaschema. The full metaschema won't be parsed until a solution to usnistgov/metaschema#228 is implemented.
Added a new databind-metaschema/pom.xml Maven module as a placeholder for new parsing code based on generated Metaschema classes.

* Switched some tests using classpath resources to file resources to make testing more stable.
Refactored model interfaces to reduce boilerplate implementations.
Added support for choice groups in the XML parsed model and code generator.
Moved IAtomicValuedItem to a more sensible location.

* Refactored annotations to consolidate ValueConstraints, AssemblyConstraints, and GroupAs as child annotations of the core BoundAssembly, BoundField, BoundFlag, and BoundChoiceGroup annotations.
Cleaned up some compile and PMD warnings. Added some Javadocs.

* Silenced some compile warnings related to m2e in eclipse. Fixed some null reference and code style warnings. Also minor reformating.
david-waltermire added a commit that referenced this issue Nov 10, 2023
Changed metapath type to indicate a difference between a Metapath that can be compiled vs a string that is to be processed in a different way. Also removed extra unnecessary ConstraintsContainerType.
Added support for flag and field instances to provide a different default value than the definition.
Reorganized the schema to group constraint types and groups.
Added support for let statements in constraints.
Added support for choice groups as a potential solution for resolving #228.
Fixed some minor content defects.
Added a draft Metaschema Metaschema in schema/metaschema/metaschema-metaschema.xml.
Adjusted Metaschema choice-group to allow for minimum cardinalities of 1 and a default unlimited max cardinality.
Created a draft Metaschema module (metaschema-module-metaschema.xml, describing the Metaschema module model.
david-waltermire added a commit that referenced this issue Nov 10, 2023
Changed metapath type to indicate a difference between a Metapath that can be compiled vs a string that is to be processed in a different way. Also removed extra unnecessary ConstraintsContainerType.
Added support for flag and field instances to provide a different default value than the definition.
Reorganized the schema to group constraint types and groups.
Added support for let statements in constraints.
Added support for choice groups as a potential solution for resolving #228.
Fixed some minor content defects.
Added a draft Metaschema Metaschema in schema/metaschema/metaschema-metaschema.xml.
Adjusted Metaschema choice-group to allow for minimum cardinalities of 1 and a default unlimited max cardinality.
Created a draft Metaschema module (metaschema-module-metaschema.xml, describing the Metaschema module model.
david-waltermire added a commit that referenced this issue Nov 10, 2023
Changed metapath type to indicate a difference between a Metapath that can be compiled vs a string that is to be processed in a different way. Also removed extra unnecessary ConstraintsContainerType.
Added support for flag and field instances to provide a different default value than the definition.
Reorganized the schema to group constraint types and groups.
Added support for let statements in constraints.
Added support for choice groups as a potential solution for resolving #228.
Fixed some minor content defects.
Added a draft Metaschema Metaschema in schema/metaschema/metaschema-metaschema.xml.
Adjusted Metaschema choice-group to allow for minimum cardinalities of 1 and a default unlimited max cardinality.
Created a draft Metaschema module (metaschema-module-metaschema.xml, describing the Metaschema module model.
david-waltermire added a commit that referenced this issue Jan 4, 2024
Changed metapath type to indicate a difference between a Metapath that can be compiled vs a string that is to be processed in a different way. Also removed extra unnecessary ConstraintsContainerType.
Added support for flag and field instances to provide a different default value than the definition.
Reorganized the schema to group constraint types and groups.
Added support for let statements in constraints.
Added support for choice groups as a potential solution for resolving #228.
Fixed some minor content defects.
Added a draft Metaschema Metaschema in schema/metaschema/metaschema-metaschema.xml.
Adjusted Metaschema choice-group to allow for minimum cardinalities of 1 and a default unlimited max cardinality.
Created a draft Metaschema module (metaschema-module-metaschema.xml, describing the Metaschema module model.
github-merge-queue bot pushed a commit that referenced this issue Jan 25, 2024
* PoC schema for metaconstraints.
Changed metapath type to indicate a difference between a Metapath that can be compiled vs a string that is to be processed in a different way. Also removed extra unnecessary ConstraintsContainerType.
Added support for flag and field instances to provide a different default value than the definition.
Reorganized the schema to group constraint types and groups.
Added support for let statements in constraints.
Added support for choice groups as a potential solution for resolving #228.
Fixed some minor content defects.
Added a draft Metaschema Metaschema in schema/metaschema/metaschema-metaschema.xml.
Adjusted Metaschema choice-group to allow for minimum cardinalities of 1 and a default unlimited max cardinality.
Created a draft Metaschema module (metaschema-module-metaschema.xml, describing the Metaschema module model.

* Adjusted the definitions for discriminator and json-value-key-flag to flatten them.

* Added missing support for deprecated on allowed value enumerations.

* Inlined a bunch of definitions that are single use.
Added missing href to import.

* Fixed discriminator value in wrong sequence location.

* Fixed broken namespace on properties.

* Fixed incorrect module short name data type.

* Fixed a problem with the unique constraint's name.
@david-waltermire david-waltermire added this to the Metaschema 1.0.0 milestone Feb 9, 2024
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this issue Apr 21, 2024
…work#254)

* Added a bunch of Javadoc comments.
Added support for flag and field instances to provide a different default value than the definition.
Implemented experimental support for let statements in constraints.
Refactored constraint parsing in the databind module.
Removed some unused code.

* Fixed maven warning caused by duplicate plugin declaration in pluginManagement.
Completed support for default value support on instances.

* Unified external constraint processing through use of an ExternalConstraintsModulePostProcessor.
Completed initial support for the MetaConstraintLoader. Still need to implement a true Metaschema-based Metaschema model to get constraint scope targeting working correctly.

* Added the start of a Metaschema Metaschema implementation by adding tests around parsing a Metaschema Metaschema. The full metaschema won't be parsed until a solution to usnistgov/metaschema#228 is implemented.
Added a new databind-metaschema/pom.xml Maven module as a placeholder for new parsing code based on generated Metaschema classes.

* Switched some tests using classpath resources to file resources to make testing more stable.
Refactored model interfaces to reduce boilerplate implementations.
Added support for choice groups in the XML parsed model and code generator.
Moved IAtomicValuedItem to a more sensible location.

* Refactored annotations to consolidate ValueConstraints, AssemblyConstraints, and GroupAs as child annotations of the core BoundAssembly, BoundField, BoundFlag, and BoundChoiceGroup annotations.
Cleaned up some compile and PMD warnings. Added some Javadocs.

* Silenced some compile warnings related to m2e in eclipse. Fixed some null reference and code style warnings. Also minor reformating.
david-waltermire added a commit to metaschema-framework/metaschema-java that referenced this issue Apr 21, 2024
* Added a bunch of Javadoc comments.
Added support for flag and field instances to provide a different default value than the definition.
Implemented experimental support for let statements in constraints.
Refactored constraint parsing in the databind module.
Removed some unused code.

* Fixed maven warning caused by duplicate plugin declaration in pluginManagement.
Completed support for default value support on instances.

* Unified external constraint processing through use of an ExternalConstraintsModulePostProcessor.
Completed initial support for the MetaConstraintLoader. Still need to implement a true Metaschema-based Metaschema model to get constraint scope targeting working correctly.

* Added the start of a Metaschema Metaschema implementation by adding tests around parsing a Metaschema Metaschema. The full metaschema won't be parsed until a solution to usnistgov/metaschema#228 is implemented.
Added a new databind-metaschema/pom.xml Maven module as a placeholder for new parsing code based on generated Metaschema classes.

* Switched some tests using classpath resources to file resources to make testing more stable.
Refactored model interfaces to reduce boilerplate implementations.
Added support for choice groups in the XML parsed model and code generator.
Moved IAtomicValuedItem to a more sensible location.

* Refactored annotations to consolidate ValueConstraints, AssemblyConstraints, and GroupAs as child annotations of the core BoundAssembly, BoundField, BoundFlag, and BoundChoiceGroup annotations.
Cleaned up some compile and PMD warnings. Added some Javadocs.

* Silenced some compile warnings related to m2e in eclipse. Fixed some null reference and code style warnings. Also minor reformating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants