Class: Lutaml::XMI::Parsers::XML
- Inherits:
-
Object
- Object
- Lutaml::XMI::Parsers::XML
- 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
-
#xmi_cache ⇒ Object
readonly
Returns the value of attribute xmi_cache.
-
#xmi_root_model ⇒ Object
readonly
Returns the value of attribute xmi_root_model.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#xmi_cache ⇒ Object (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_model ⇒ Object (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
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 22 def self.parse(xml, = {}) sparx_root = Xmi::Sparx::SparxRoot xmi_doc = Nokogiri::XML(File.read(xml)) namespace = xmi_doc.at_xpath("//xmi:XMI").namespaces if namespace["xmlns:uml"].split("/").last == "20131001" sparx_root = Xmi::Sparx::SparxRoot2013 end xml_content = File.read(xml) xmi_model = sparx_root.from_xml(xml_content) new.parse(xmi_model) end |
Instance Method Details
#parse(xmi_model) ⇒ Lutaml::Uml::Document
37 38 39 40 41 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 37 def parse(xmi_model) @xmi_cache = {} @xmi_root_model = xmi_model ::Lutaml::Uml::Document.new(serialize_to_hash(xmi_model)) end |