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:



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

def parse(xml, _options = {})
  xmi_model = get_xmi_model(xml)
  new.parse(xmi_model)
end

.serialize_generalization_by_name(xml, name) ⇒ Hash

Parameters:

  • xml (String)

    path to xml

  • name (String)

Returns:

  • (Hash)


45
46
47
48
# File 'lib/lutaml/xmi/parsers/xml.rb', line 45

def serialize_generalization_by_name(xml, name)
  xmi_model = get_xmi_model(xml)
  new.serialize_generalization_by_name(xmi_model, name)
end

.serialize_xmi(xml) ⇒ Hash

Parameters:

  • xml (String)

    path to xml

Returns:

  • (Hash)


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

def serialize_xmi(xml)
  xmi_model = get_xmi_model(xml)
  new.serialize_xmi(xmi_model)
end

.serialize_xmi_to_liquid(xml) ⇒ Liquid::Drop

Parameters:

  • xml (String)

    path to xml

Returns:

  • (Liquid::Drop)


37
38
39
40
# File 'lib/lutaml/xmi/parsers/xml.rb', line 37

def serialize_xmi_to_liquid(xml)
  xmi_model = get_xmi_model(xml)
  new.serialize_xmi_to_liquid(xmi_model)
end

Instance Method Details

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

Parameters:

  • xmi_model (Shale::Mapper)

Returns:



61
62
63
64
65
66
67
# File 'lib/lutaml/xmi/parsers/xml.rb', line 61

def parse(xmi_model)
  @xmi_cache = {}
  @xmi_root_model = xmi_model
  serialized_hash = serialize_xmi(xmi_model)

  ::Lutaml::Uml::Document.new(serialized_hash)
end

#serialize_generalization_by_name(xmi_model, name) ⇒ Hash

Parameters:

  • xmi_model (Shale::Mapper)
  • name (String)

Returns:

  • (Hash)


90
91
92
93
94
95
# File 'lib/lutaml/xmi/parsers/xml.rb', line 90

def serialize_generalization_by_name(xmi_model, name)
  @xmi_cache = {}
  @xmi_root_model = xmi_model
  klass = find_klass_packaged_element_by_name(name)
  serialize_generalization(klass)
end

#serialize_xmi(xmi_model) ⇒ Object

return [Hash]

Parameters:

  • xmi_model (Shale::Mapper)


71
72
73
74
75
# File 'lib/lutaml/xmi/parsers/xml.rb', line 71

def serialize_xmi(xmi_model)
  @xmi_cache = {}
  @xmi_root_model = xmi_model
  serialize_to_hash(xmi_model)
end

#serialize_xmi_to_liquid(xmi_model) ⇒ Object

return [Liquid::Drop]

Parameters:

  • xmi_model (Shale::Mapper)


79
80
81
82
83
84
85
# File 'lib/lutaml/xmi/parsers/xml.rb', line 79

def serialize_xmi_to_liquid(xmi_model)
  @xmi_cache = {}
  @xmi_root_model = xmi_model
  serialized_hash = serialize_xmi(xmi_model)

  ::Lutaml::XMI::RootDrop.new(serialized_hash)
end