Class: Metanorma::Plugin::Lutaml::LutamlXsdPreprocessor

Inherits:
BasePreprocessor
  • Object
show all
Defined in:
lib/metanorma/plugin/lutaml/lutaml_xsd_preprocessor.rb

Overview

Preprocessor for XSD (XML Schema Definition) files. Parses XSD via lutaml-model’s XSD parser and exposes the schema object to Liquid templates.

Two syntaxes are supported:

Block:  [lutaml_xsd, path, context, options] .... ----
Direct: lutaml_xsd::path[context, template, options]

Caching: parsed XSD results are cached at two levels:

  • Class-level (CACHE) persists across document invocations

  • Document-level (document.attributes) within a single document’s processing

Constant Summary collapse

CACHE =
CacheStore.new
XSD_PREPROCESSOR_REGEX =
%r{
  ^                            # Start of line
  \[                           # Opening bracket
  (?:\blutaml_xsd\b)           # lutaml_xsd
  ,                            # Comma separator
  (?<index_names>[^,]+)?       # Optional index names
  ,?                           # Optional comma
  (?<context_name>[^,]+)?      # Optional context name
  (?<options>,.*)?             # Optional options
  \]                           # Closing bracket
}x
XSD_DIRECT_REGEX =
%r{
  ^\s*                         # Start of line
  lutaml_xsd::                 # Macro prefix
  (?<file_path>[^\[]+?)        # XSD file path
  \[                           # Opening bracket
  (?<context_name>[^,]+)       # Context name
  ,\s*                         # Comma separator
  (?<template>[^,\]]+)         # Template file path
  (?<options>,[^\]]+)?         # Optional options
  \]                           # Closing bracket
  \s*$                         # End of line
}x

Constants inherited from BasePreprocessor

BasePreprocessor::FILE_SYSTEM_PATTERNS

Constants included from Utils

Utils::LUTAML_EXP_IDX_TAG

Instance Method Summary collapse

Methods inherited from BasePreprocessor

#process

Methods included from Utils

create_liquid_environment, error_signature, load_express_from_folder, load_express_from_index, load_express_repo_from_cache, load_express_repo_from_path, load_express_repositories, notify_render_errors, parse_document_express_indexes, processed_lines, relative_file_path, render_liquid_string, save_express_repo_to_cache

Constructor Details

#initialize(_config = {}) ⇒ LutamlXsdPreprocessor

Returns a new instance of LutamlXsdPreprocessor.



47
48
49
# File 'lib/metanorma/plugin/lutaml/lutaml_xsd_preprocessor.rb', line 47

def initialize(_config = {})
  super
end