Class: Eeml::LibXMLEemlParserV005

Inherits:
Object
  • Object
show all
Includes:
Exceptions, LibXML
Defined in:
lib/eeml/libxml_eeml_parser_v005.rb

Overview

a parser for xml eeml v005, implemented with LibXML

Constant Summary collapse

@@eeml_version =
Constants::EEML['0.5.0']

Instance Method Summary collapse

Instance Method Details

#make_environment_from_xml(xml_str, given_environment = nil) ⇒ Object

take an xml string, and create an Environment from it. If an optional environment is given, that will be populated (overwritten) instead of a new environment.

Raises:



13
14
15
16
17
18
19
# File 'lib/eeml/libxml_eeml_parser_v005.rb', line 13

def make_environment_from_xml(xml_str, given_environment = nil)
  doc = parse_xml(xml_str)
  raise MissingNamespace if doc.root.namespaces.namespace.blank?
  env = given_environment || Environment.new
  #TODO: what has to be reset in a given environment before passing it for re-population?
  return extract_environment_from_doc(doc, env)
end

#make_environments_from_xml(xml_str) ⇒ Object

take an xml string containing zero or more environment nodes, and create an array of Environment objects from it.

Raises:



22
23
24
25
26
# File 'lib/eeml/libxml_eeml_parser_v005.rb', line 22

def make_environments_from_xml(xml_str)
  doc = parse_xml(xml_str)
  raise MissingNamespace if doc.root.namespaces.namespace.blank?
  return extract_environments_from_doc(doc)
end