Class: Lutaml::XMI::Parsers::XML

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xmi/parsers/xml.rb

Overview

Class for parsing .xmi schema files into ::Lutaml::Uml::Document

Constant Summary collapse

LOWER_VALUE_MAPPINGS =
{
  "0" => "C",
  "1" => "M",
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xmi_cacheObject (readonly)

Returns the value of attribute xmi_cache.



17
18
19
# File 'lib/lutaml/xmi/parsers/xml.rb', line 17

def xmi_cache
  @xmi_cache
end

#xmi_root_modelObject (readonly)

Returns the value of attribute xmi_root_model.



17
18
19
# File 'lib/lutaml/xmi/parsers/xml.rb', line 17

def xmi_root_model
  @xmi_root_model
end

Class Method Details

.parse(xml, _options = {}) ⇒ Lutaml::Uml::Document

Parameters:

  • xml (String)

    path to xml

  • options (Hash)

    options for parsing

Returns:



22
23
24
25
26
# File 'lib/lutaml/xmi/parsers/xml.rb', line 22

def self.parse(xml, _options = {})
  xml_content = File.read(xml)
  xmi_model = Xmi::Sparx::SparxRoot.parse_xml(xml_content)
  new.parse(xmi_model)
end

Instance Method Details

#parse(xmi_model) ⇒ Lutaml::Uml::Document

Parameters:

  • xmi_model (Shale::Mapper)

Returns:



30
31
32
33
34
# File 'lib/lutaml/xmi/parsers/xml.rb', line 30

def parse(xmi_model)
  @xmi_cache = {}
  @xmi_root_model = xmi_model
  ::Lutaml::Uml::Document.new(serialize_to_hash(xmi_model))
end