Class: SiSU_Rexml::Rexml
- Inherits:
-
Object
- Object
- SiSU_Rexml::Rexml
- Defined in:
- lib/sisu/rexml.rb
Instance Method Summary collapse
-
#initialize(md, fno) ⇒ Rexml
constructor
A new instance of Rexml.
- #xml ⇒ Object
Constructor Details
#initialize(md, fno) ⇒ Rexml
Returns a new instance of Rexml.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/sisu/rexml.rb', line 78 def initialize(md,fno) @md,@fno=md,fno @env=SiSU_Env::InfoEnv.new(@md.fns) @prog=SiSU_Env::InfoProgram.new #(md.fns) #if md if File.file?(@fno) @fnap=@fno #index.xml causes problems with index.html in server config end @e_head='/document/head' @e_title='/document/head/title' @e_object='/document/body/object' @e_ocn='/document/body/object/ocn' @e_text='/document/body/object/text' @e_endnote='/document/body/object/endnote' end |
Instance Method Details
#xml ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/sisu/rexml.rb', line 92 def xml begin if FileTest.file?(@fnap) if @prog.rexml !=false \ and FileTest.directory?('/usr/lib/ruby/1.8/rexml/') #note values can be other than true xmlfile=IO.readlines(@fnap,'').join begin @xmldoc=REXML::Document.new xmlfile SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], 'invert', 'REXML', "XML document #{@fnap} loaded" ).colorize unless @md.opt.act[:quiet][:set]==:on if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on) @xmldoc.elements.each(@e_head) do |e| SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], 'brown', e ).colorize unless @md.opt.act[:quiet][:set]==:on end end rescue REXML::ParseException puts 'broken XML' end end else SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], 'fuchsia', "File Not Found #{xmlfile}", 'requested XML processing skipped' ).colorize unless @md.opt.act[:quiet][:set]==:on exit end rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do __LINE__.to_s + ':' + __FILE__ end ensure end end |