Class: Fabulator::TagLib::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/fabulator/tag_lib/transformations.rb

Instance Method Summary collapse

Constructor Details

#initializeFormat

Returns a new instance of Format.



35
36
# File 'lib/fabulator/tag_lib/transformations.rb', line 35

def initialize
end

Instance Method Details

#get_root_namespacesObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fabulator/tag_lib/transformations.rb', line 52

def get_root_namespaces
  if !@xslt_doc.nil?
    # extract namespace declarations from root element
    ret = [ ]
    @xslt_doc.root.namespaces.each { |ns|
      ret << ns.href
    }
    ret
  else
    []
  end
end

#transform(doc, opts) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/fabulator/tag_lib/transformations.rb', line 38

def transform(doc, opts)
  if !@xslt.nil?
    @xslt.apply(doc, opts) 
  else
    doc
  end
end

#xslt_from_file(fpath) ⇒ Object



46
47
48
49
50
# File 'lib/fabulator/tag_lib/transformations.rb', line 46

def xslt_from_file(fpath)
  @xslt_file = fpath
  @xslt_doc = LibXML::XML::Document.file(@xslt_file)
  @xslt = LibXSLT::XSLT::Stylesheet.new(@xslt_doc)
end