Module: FN::Document::ClassMethods

Includes:
Util
Included in:
FN::Document
Defined in:
lib/fn/document.rb

Instance Method Summary collapse

Methods included from Util

#raise_unless_xml_doc, #raise_unless_xml_node

Instance Method Details

#file(file, options = {}) ⇒ Object

Reads XML from a file, and returns the FN::Document



27
28
29
# File 'lib/fn/document.rb', line 27

def file(file, options = {})
  new(XML::Document.file(file), options)
end

#migrate_from(xml) ⇒ Object

Creates a new FN::Document from an XML object that is in the old- school (original) style



17
18
19
20
21
22
23
24
# File 'lib/fn/document.rb', line 17

def migrate_from(xml)
  raise_unless_xml_doc xml
  @xslt ||= XSLT::Stylesheet.new(
            XML::Document.file(
            File.dirname(__FILE__) + "/migrate.xslt"
          ))
  return FN::Document.new(@xslt.apply(xml))
end

#string(string, options = {}) ⇒ Object

Reads XML from a string, and returns the FN::Document



32
33
34
# File 'lib/fn/document.rb', line 32

def string(string, options = {})
  new(XML::Document.string(string), options)
end