Skip to content

feat: lutaml_xsd command support - #246

Merged
ronaldtse merged 5 commits into
mainfrom
feature/lutaml_xsd_command
May 13, 2026
Merged

feat: lutaml_xsd command support#246
ronaldtse merged 5 commits into
mainfrom
feature/lutaml_xsd_command

Conversation

@suleman-uzair

Copy link
Copy Markdown
Member

Metanorma PR checklist

This PR incorporates the lutaml_xsd command, allowing access to the XSD schema's processing.

closes #176

This comment was marked as outdated.

@suleman-uzair
suleman-uzair requested a review from Copilot July 17, 2025 07:04

This comment was marked as outdated.

@suleman-uzair
suleman-uzair requested a review from Copilot July 17, 2025 07:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR incorporates the lutaml_xsd command to support processing XSD (XML Schema Definition) files using Liquid templates. The feature allows users to extract and render schema elements, complex types, and other XSD components through template-based documentation generation.

Key Changes

  • Adds LutaML XSD preprocessor functionality for processing XML Schema files
  • Implements base preprocessor class to share common functionality between preprocessors
  • Includes comprehensive test coverage for XSD processing with UnitsML and OMML schemas

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/metanorma/plugin/lutaml/lutaml_xsd_preprocessor.rb New preprocessor class implementing XSD-specific processing logic
lib/metanorma/plugin/lutaml/base_preprocessor.rb Base class extracted from existing preprocessor to share common functionality
lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb Refactored to inherit from BasePreprocessor
spec/metanorma/plugin/lutaml/lutaml_xsd_preprocessor_spec.rb Comprehensive test suite for XSD preprocessor functionality
spec/fixtures/lutaml/xsd_schemas/unitsml-v1.0-csd04.xsd Test fixture: UnitsML XSD schema for testing
spec/fixtures/lutaml/xsd_schemas/omml.xsd Test fixture: OMML XSD schema for testing
docs/usages/lutaml-xsd.adoc Documentation for the new lutaml_xsd command usage

yaml = Zlib::Inflate.inflate(yaml_compressed)
cache = Expressir::Model::Cache.from_yaml(yaml)
cache.version = "2.1.22"
cache.version = "2.1.23"

Copilot AI Jul 17, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The hardcoded version string "2.1.23" appears to be test-specific and may become outdated. Consider using a constant or making this version configurable to avoid maintenance issues when the actual version changes.

Suggested change
cache.version = "2.1.23"
cache.version = CACHE_VERSION

Copilot uses AI. Check for mistakes.
@opoudjis

opoudjis commented May 6, 2026

Copy link
Copy Markdown
Contributor

@suleman-uzair @HassanAkbar @ronaldtse What is the status of this PR?

@suleman-uzair

Copy link
Copy Markdown
Member Author

@suleman-uzair @HassanAkbar @ronaldtse What is the status of this PR?

@opoudjis, we’ve made some required upstream changes in lutaml-model and lutaml-xsd. I’ll update this PR and the dependent #251 accordingly, and let you know once both are finalized.

@suleman-uzair
suleman-uzair force-pushed the feature/lutaml_xsd_command branch from cd2dcd9 to cb8bdc9 Compare May 6, 2026 15:01
ronaldtse added 4 commits May 13, 2026 20:03
Move shared preprocessor logic (block parsing, Liquid rendering,
index lookup) into BasePreprocessor. LutamlPreprocessor now only
implements format-specific hooks: load_lutaml_file dispatches to
Express::Parsers::Exp or Uml::Parsers::Dsl, update_repo handles
ExpFile/Repository unwrapping and remark decoration, template uses
the custom Liquid environment with keyiterator tag and filters.
Lutaml::Parser was removed in lutaml 0.10. Replace all call sites:
- Lutaml::Express::Parsers::Exp.parse_cache for cache loading
- Expressir::Express::Parser.from_files for multi-file EXPRESS loading
New LutamlXsdPreprocessor < BasePreprocessor handles [lutaml_xsd] blocks.
Parses XSD files via lutaml-model, renders with Liquid, and caches parse
results in both a class variable and per-document attributes to avoid
re-parsing the same file across blocks or documents.
…paths

- find_packaged_klass_by_path now iterates all candidates instead of
  returning the first match by name, correctly disambiguating classes
  with the same name in different packages.
- find_packaged_klass strips the root model name prefix from absolute
  paths (e.g. ::EA_Model::...) so match_parent_chain? walks the
  actual parent chain without hitting a missing root entry.
- Extract match_parent_chain? helper for clarity.
@ronaldtse
ronaldtse force-pushed the feature/lutaml_xsd_command branch from 7a835db to b77c3a8 Compare May 13, 2026 12:09
Test now uses File.basename(Dir.pwd) instead of hardcoded directory
name, making it work in any checkout location.

Update Gemfile and Gemfile.lock for lutaml-model 0.8.7.
@ronaldtse
ronaldtse force-pushed the feature/lutaml_xsd_command branch from b77c3a8 to bf5bc38 Compare May 13, 2026 13:08
@ronaldtse
ronaldtse merged commit 6feed78 into main May 13, 2026
14 checks passed
@ronaldtse
ronaldtse deleted the feature/lutaml_xsd_command branch May 13, 2026 15:13
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.

Implement new lutaml_xsd command to allow accessing XSD files in Liquid

4 participants