Class | Core::Providers::Multiverse::Parser |
In: |
core/serviceproviders/multiverse/parser.rb
|
Parent: | Object |
Parse the contents of the XML file or string and return a Universe
object that contains the elements defined in the file.
+xmlsource+ is a hash, if it contains a :file element, the XML file is parsed, otherwise, a :string element containing the XML source is expected. If no :file or :string elements are passed an exception will be raised.
# File core/serviceproviders/multiverse/parser.rb, line 110 def parse(source = {}) xmlsource = check_xml_source(source) begin doc = REXML::Document.new(xmlsource) rescue REXML::ParseException => e # re-raise exception raise Core::Exceptions::Multiverse::UniverseParsingException.new(e) end check_xml_structure(doc) u = Universe.new if @directory u.path = @directory end doc.root.each_element do |section| parse_section( doc, u, section.name ) end return u end