Module: Chemicalml::VersionedParser

Included in:
Cml::Schema24, Cml::Schema3
Defined in:
lib/chemicalml/versioned_parser.rb

Overview

Shared parse entrypoint for versioned schema modules. Each schema module (Cml::Schema3, Cml::Schema24) extends this; it provides .parse(xml) that ensures the schema's wire classes are registered with Lutaml::Model::GlobalContext, then delegates to Document.from_xml(xml, register: context_id).

Mirrors Mml::VersionedParser.

Instance Method Summary collapse

Instance Method Details

#configurationObject



24
25
26
# File 'lib/chemicalml/versioned_parser.rb', line 24

def configuration
  const_get(:Configuration)
end

#document_classObject



20
21
22
# File 'lib/chemicalml/versioned_parser.rb', line 20

def document_class
  const_get(:Document)
end

#parse(xml, namespace_exist: true) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/chemicalml/versioned_parser.rb', line 12

def parse(xml, namespace_exist: true)
  configuration.ensure_registered!
  document_class.from_xml(
    xml_input(xml, namespace_exist),
    register: configuration.context_id
  )
end