Class: XML_XSI

Inherits:
Object
  • Object
show all
Defined in:
lib/validate_xml_xsi.rb

Defined Under Namespace

Classes: Schema

Class Method Summary collapse

Class Method Details

.parse(obj) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/validate_xml_xsi.rb', line 5

def self.parse(obj)
  filename = nil
  obj = File::read(filename = obj) if obj.is_a?(String) && File::exist?(obj)
  xml_doc = Nokogiri::XML.parse(obj) { |cfg| cfg.strict.pedantic.nonet }
  xml_doc.instance_variable_set('@filename', filename)
  xml_doc.define_singleton_method(:filename) { instance_variable_get('@filename') }
  xml_doc
end