class RubyXL::OOXMLTopLevelObject

their own .xml files in .xslx zip container.
Extension class providing functionality for top-level OOXML objects that are represented by

def self.parse_file(dirpath, file_path = nil)

* +dirpath+ - path to the directory with the unzipped .xslx contents.
=== Parameters
directory containing the unzipped contents of .xslx
Generates the top-level OOXML object by parsing its XML file from the temporary
def self.parse_file(dirpath, file_path = nil)
  file_path = file_path || self.xlsx_path
  case dirpath
  when String then
    full_path = File.join(dirpath, file_path)
    return nil unless File.exist?(full_path)
    # Making sure that the file will be automatically closed immediately after it has been read

    File.open(full_path, 'r') { |f| parse(f) }
  when Zip::File then
    file_path = file_path.relative_path_from(::Pathname.new("/")) if file_path.absolute? # Zip doesn't like absolute paths.

    entry = dirpath.find_entry(file_path)
    # Accomodate for Nokogiri Java implementation which is incapable of reading from a stream

    entry && (entry.get_input_stream { |f| parse(defined?(JRUBY_VERSION) ? f.read : f) })
  end
end

def self.set_namespaces(namespace_hash)

'http://schemas.openxmlformats.org/officeDocument/2006/relationships' => 'r')
set_namespaces('http://schemas.openxmlformats.org/spreadsheetml/2006/main' => '',
==== Examples
* +namespace_hash+ - Hash of namespaces in the form of "prefix" => "url"
=== Parameters
Sets the list of namespaces on this object to be added when writing out XML. Valid only on top-level objects.
def self.set_namespaces(namespace_hash)
  self.class_variable_set(:@@ooxml_namespaces, namespace_hash)
end

def add_to_zip(zip_stream)

* +zipfile+ - ::Zip::File to which the resulting XNMML should be added.
=== Parameters
Saves the contents of the object as XML to respective location in .xslx zip container.
def add_to_zip(zip_stream)
  xml_string = write_xml
  return if xml_string.empty?
  zip_stream.put_next_entry(self.xlsx_path.relative_path_from(::Pathname.new("/")))
  zip_stream.write(xml_string)
end

def file_index

def file_index
  root.rels_hash[self.class].index{ |f| f.equal?(self) }.to_i + 1
end

def xlsx_path

is located within the .xslx zip container.
Prototype method. For top-level OOXML object, returns the path at which the current object's XML file
def xlsx_path
  raise 'Subclass responsebility'
end