Added rng model generation#699
Open
HassanAkbar wants to merge 17 commits into
Open
Conversation
627a823 to
303b085
Compare
…ompiler-to-models
…ompiler-to-models
1ef973d to
15f09f9
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds RELAX NG (RNG) schema compilation support to generate Lutaml model classes from RNG grammars (fixes #9), and refactors the existing XSD compiler into a shared “definitions + renderers + compiled output” architecture that can be reused by multiple schema compilers.
Changes:
- Add
Schema.from_relaxngentry point and implementLutaml::Model::Schema::RngCompilerwith fixtures and documentation. - Refactor XSD compilation to emit
Definitions::*specs and render via sharedRenderers::*, with sharedCompiledOutput,FileWriter,ClassLoader, andRegistryGeneratorinfrastructure. - Introduce shared templates (
Schema::Templates) and namespace naming helpers reused across schema compilers.
Reviewed changes
Copilot reviewed 92 out of 92 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| Gemfile | Adds rng dependency via git for development/tests. |
| README.adoc | Documents RELAX NG schema compilation and usage patterns. |
| lib/lutaml/xml.rb | Registers Schema.from_relaxng method and delegates to RngCompiler. |
| lib/lutaml/model/utils.rb | Adds Utils.last_of_split helper. |
| lib/lutaml/model/schema.rb | Autoloads new shared schema infrastructure, definitions, renderers, and RNG compiler. |
| lib/lutaml/model/schema/class_loader.rb | New shared loader to write compiled output to temp dir and load via registry. |
| lib/lutaml/model/schema/compiled_output.rb | New shared compilation output container for models/namespaces and rendered sources. |
| lib/lutaml/model/schema/file_writer.rb | New shared writer for namespaced/flat output plus registry generation. |
| lib/lutaml/model/schema/module_nesting.rb | New helper for module wrapper emission. |
| lib/lutaml/model/schema/namespace_naming.rb | New helper to derive namespace class names/prefixes from URI. |
| lib/lutaml/model/schema/registry_generator.rb | New base registry generator used by compilers. |
| lib/lutaml/model/schema/templates.rb | New shared ERB templates for generated classes/types/namespaces. |
| lib/lutaml/model/schema/definitions.rb | New autoload entrypoint for schema definition objects. |
| lib/lutaml/model/schema/definitions/attribute.rb | New definition type for attributes/elements. |
| lib/lutaml/model/schema/definitions/choice.rb | New definition type for choice blocks. |
| lib/lutaml/model/schema/definitions/facet.rb | New definition type for restriction facets. |
| lib/lutaml/model/schema/definitions/group_import.rb | New definition type for XSD group imports in members. |
| lib/lutaml/model/schema/definitions/member_walk.rb | New traversal helper for heterogeneous member trees. |
| lib/lutaml/model/schema/definitions/model.rb | New definition type for generated Serializable models. |
| lib/lutaml/model/schema/definitions/namespace.rb | New definition type for XML namespace classes. |
| lib/lutaml/model/schema/definitions/restricted_type.rb | New definition type for restricted simple types. |
| lib/lutaml/model/schema/definitions/sequence.rb | New definition type for sequences. |
| lib/lutaml/model/schema/definitions/simple_content.rb | New XSD simpleContent sidecar definition. |
| lib/lutaml/model/schema/definitions/transform_facet.rb | New XSD-only transform facet definition. |
| lib/lutaml/model/schema/definitions/type_ref.rb | New type reference wrapper definition. |
| lib/lutaml/model/schema/definitions/union_type.rb | New definition type for union value types. |
| lib/lutaml/model/schema/definitions/xml_root.rb | New definition type describing XML root directive kind/name. |
| lib/lutaml/model/schema/renderers.rb | New autoload entrypoint for renderers. |
| lib/lutaml/model/schema/renderers/member_decls.rb | Renders attribute declarations from definitions. |
| lib/lutaml/model/schema/renderers/mappings.rb | Renders XML mapping blocks from definitions. |
| lib/lutaml/model/schema/renderers/model.rb | Renders Definitions::Model to Ruby source using shared templates. |
| lib/lutaml/model/schema/renderers/namespace.rb | Renders Definitions::Namespace to Ruby source. |
| lib/lutaml/model/schema/renderers/registration.rb | Renders register/register_class_with_id boilerplate. |
| lib/lutaml/model/schema/renderers/required_files_calculator.rb | Computes dependencies/require lines for generated models. |
| lib/lutaml/model/schema/renderers/restricted_type.rb | Renders restricted types to Ruby source. |
| lib/lutaml/model/schema/renderers/union.rb | Renders union types to Ruby source. |
| lib/lutaml/model/schema/rng_compiler.rb | New RNG compiler orchestrator (parse, compile, output). |
| lib/lutaml/model/schema/rng_compiler/define_classifier.rb | Classifies defines into restricted/union vs structural models. |
| lib/lutaml/model/schema/rng_compiler/element_visitor.rb | Walks RNG AST to build model/type definitions. |
| lib/lutaml/model/schema/rng_compiler/member_collector.rb | Scratch accumulator for choice/group member collection. |
| lib/lutaml/model/schema/rng_compiler/rng_helpers.rb | Centralized RNG AST helper predicates and facet builders. |
| lib/lutaml/model/schema/rng_compiler/value_type_resolver.rb | Resolves leaf value types (primitive/ref/anonymous restrictions). |
| lib/lutaml/model/schema/xml_compiler.rb | Refactors XSD compilation to use SpecBuilder + shared output infrastructure. |
| lib/lutaml/model/schema/xml_compiler/element_order.rb | New helper for resolved traversal order of XSD AST nodes. |
| lib/lutaml/model/schema/xml_compiler/registry_generator.rb | Updates XSD registry generator to subclass shared base and add phases. |
| lib/lutaml/model/schema/xml_compiler/spec_builder.rb | New XSD SpecBuilder orchestrating two-pass collection/build. |
| lib/lutaml/model/schema/xml_compiler/supported_data_types.rb | New built-in XSD type table module. |
| lib/lutaml/model/schema/xml_compiler/spec_builder/complex_types.rb | New XSD complex-type builder producing model specs. |
| lib/lutaml/model/schema/xml_compiler/spec_builder/members.rb | New XSD member builder producing attribute/sequence/choice/group specs. |
| lib/lutaml/model/schema/xml_compiler/spec_builder/simple_types.rb | New XSD simple-type builder producing restricted/union specs. |
| lib/lutaml/model/schema/xml_compiler/attribute.rb | Removed legacy XSD compiler implementation (superseded by definitions/renderers). |
| lib/lutaml/model/schema/xml_compiler/attribute_group.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/choice.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/complex_content.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/complex_content_restriction.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/complex_type.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/element.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/group.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/restriction.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/sequence.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/simple_content.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/simple_type.rb | Removed legacy XSD compiler implementation. |
| lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb | Removed legacy XSD namespace class generator (replaced by shared definitions/renderers). |
| spec/lutaml/model/utils_spec.rb | Adds coverage for Utils.last_of_split. |
| spec/lutaml/xml/schema/compiler_spec.rb | Updates XSD compiler spec expectations to new TypeRef / builder structure. |
| spec/lutaml/model/schema/renderers/model_spec.rb | New renderer unit tests for model rendering. |
| spec/lutaml/model/schema/renderers/namespace_spec.rb | New renderer unit tests for namespace rendering. |
| spec/lutaml/model/schema/renderers/restricted_type_spec.rb | New renderer unit tests for restricted type rendering. |
| spec/lutaml/model/schema/renderers/union_spec.rb | New renderer unit tests for union rendering. |
| spec/fixtures/xml/schema/rng/address_book.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/book.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/fixed_value.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/full_name.rng | New RNG fixture (issue #9 regression). |
| spec/fixtures/xml/schema/rng/integer_range.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/list_type.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/namespaced.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/paragraph.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/person.rng | New RNG fixture. |
| spec/fixtures/xml/schema/rng/union.rng | New RNG fixture. |
| spec/lutaml/xml/schema/compiler/attribute_group_spec.rb | Removes legacy unit spec (superseded by new architecture tests). |
| spec/lutaml/xml/schema/compiler/attribute_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/choice_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/complex_content_restriction_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/complex_content_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/complex_type_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/element_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/group_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/restriction_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/sequence_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/simple_content_spec.rb | Removes legacy unit spec. |
| spec/lutaml/xml/schema/compiler/simple_type_spec.rb | Removes legacy unit spec. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #9