From 1323f18af45ea0d3aaef5cd9ead0efb5de8b9729 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 19 Apr 2015 14:44:38 -0400 Subject: c<-d: sync, roll develop into current dir branch (5==6) * two dir branches, same library contents (v5 synced & updated with v6) --- lib/sisu/current/xml_dom.rb | 134 +++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 64 deletions(-) (limited to 'lib/sisu/current/xml_dom.rb') diff --git a/lib/sisu/current/xml_dom.rb b/lib/sisu/current/xml_dom.rb index 9707deec..766b2891 100644 --- a/lib/sisu/current/xml_dom.rb +++ b/lib/sisu/current/xml_dom.rb @@ -64,10 +64,11 @@ module SiSU_XML_DOM include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb include SiSU_XML_Format + require_relative 'xml_persist' # xml_persist.rb require_relative 'rexml' # rexml.rb include SiSU_Rexml require_relative 'shared_metadata' # shared_metadata.rb - @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0 + @@alt_id_count=0 @@tablefoot='' class Source def initialize(opt) @@ -158,18 +159,22 @@ module SiSU_XML_DOM require_relative 'txt_shared' # txt_shared.rb include SiSU_TextUtils require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml - @@xml={ body: [], open: [], close: [], head: [], sc: [] } def initialize(particulars) @env, @md, @ao_arr= particulars.env,particulars.md,particulars.ao_array @trans=SiSU_XML_Munge::Trans.new(@md) @sys=SiSU_Env::SystemCall.new + @per=SiSU_XML_Persist::Persist.new end def songsheet - pre - @data=markup(@ao_arr) - post - publish + begin + pre + @data=markup(@ao_arr) + post + publish + ensure + SiSU_XML_Persist::Persist.new.persist_init + end end protected def xml_markup(dob='') @@ -182,7 +187,7 @@ module SiSU_XML_DOM end def xml_head metadata=SiSU_Metadata::Summary.new(@md).xml_dom.metadata - @@xml[:head] << metadata + @per.head << metadata end def xml_sc(md='') sc=if @md.sc_info @@ -204,7 +209,7 @@ module SiSU_XML_DOM WOK else '' end - @@xml[:sc]=sc + @per.sc=sc end def xml_element(dob,xml_el='',xml_content='',type='norm') n=n1=n2=n3=0 @@ -221,7 +226,7 @@ WOK else '' end xml_el ||='' - @@xml[:body] <<< #{Ax[:tab]*n2} @@ -262,26 +267,26 @@ WOK if @cont[1] \ or @cont[2] \ or @cont[3] - @@xml[:body] << "#{Ax[:tab]*5}" + @per.body << "#{Ax[:tab]*5}" end @cont[1]=false if @cont[1] @cont[2]=false if @cont[2] @cont[3]=false if @cont[3] ####### attempt to close contents if @copen[4] # 4~ - [4,3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}" } @copen[1]=@copen[2]=@copen[3]=@copen[4]=false elsif @copen[3] # 3~ - [3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}" } @copen[1]=@copen[2]=@copen[3]=false elsif @copen[2] # 2~ - [2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [2,1].each { |v| @per.body << "#{Ax[:tab]*n}" } @copen[1]=@copen[2]=@copen[3]=false elsif @copen[1] # 1~ - [1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [1].each { |v| @per.body << "#{Ax[:tab]*n}" } @copen[1]=@copen[2]=@copen[3]=false end - @@xml[:body] << "#{Ax[:tab]*y}" if @level[x] + @per.body << "#{Ax[:tab]*y}" if @level[x] @level[x]=false end when 4..7 @@ -295,29 +300,29 @@ WOK xml_content="\n#{Ax[:tab]*5}" case lv when 4 - @@xml[:body] << "#{Ax[:tab]*5}" if @cont[1] + @per.body << "#{Ax[:tab]*5}" if @cont[1] if @copen[4]==true # 4~ - [4,3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}" } elsif @copen[3]==true # 3~ - [3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}" } elsif @copen[2]==true # 2~ - [2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [2,1].each { |v| @per.body << "#{Ax[:tab]*n}" } elsif @copen[1]==true # 1~ - [1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [1].each { |v| @per.body << "#{Ax[:tab]*n}" } end @cont[1]=true when 5 if @cont[3] \ or @cont[2] \ or @cont[1] - @@xml[:body] << "#{Ax[:tab]*5}" + @per.body << "#{Ax[:tab]*5}" end if @copen[4]==true #4~ - [4,3,2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [4,3,2].each { |v| @per.body << "#{Ax[:tab]*n}" } elsif @copen[3]==true #3~ - [3,2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [3,2].each { |v| @per.body << "#{Ax[:tab]*n}" } elsif @copen[2]==true #2~ - [2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [2].each { |v| @per.body << "#{Ax[:tab]*n}" } end @cont[2]=true when 6 @@ -325,12 +330,12 @@ WOK or @cont[3] \ or @cont[2] \ or @cont[1] - @@xml[:body] << "#{Ax[:tab]*5}" + @per.body << "#{Ax[:tab]*5}" end if @copen[4] #4~ - [4,3].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [4,3].each { |v| @per.body << "#{Ax[:tab]*n}" } elsif @copen[3] #3~ - [3].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [3].each { |v| @per.body << "#{Ax[:tab]*n}" } end @cont[3]=true when 7 @@ -338,10 +343,10 @@ WOK or @cont[3] \ or @cont[2] \ or @cont[1] - @@xml[:body] << "#{Ax[:tab]*5}" + @per.body << "#{Ax[:tab]*5}" end if @copen[4] #4~ - [4].each { |v| @@xml[:body] << "#{Ax[:tab]*n}" } + [4].each { |v| @per.body << "#{Ax[:tab]*n}" } end @cont[4]=true end @@ -357,15 +362,15 @@ WOK if defined? dob.obj # main text, contents, body KEEP if defined? dob.ocn \ and dob.ocn - @@xml[:body] << %{#{Ax[:tab]*6}} - @@xml[:body] << %{#{Ax[:tab]*7}#{dob.ocn}} if defined? dob.ocn + @per.body << %{#{Ax[:tab]*6}} + @per.body << %{#{Ax[:tab]*7}#{dob.ocn}} if defined? dob.ocn end - #@@xml[:body] << %{#{Ax[:tab]*7}#{dob.obj}} - #@@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*7}} - @@xml[:body] << %{#{Ax[:tab]*6}} + #@per.body << %{#{Ax[:tab]*7}#{dob.obj}} + #@per.body << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*7}} + @per.body << %{#{Ax[:tab]*6}} end end def block_structure(dob) @@ -523,16 +528,16 @@ WOK y=x - 1; v=x - 3 if @level[x]==true #2004w36 bug fix? watch/test previous logic broke on free.for.all @coontent_flag introduced if @content_flag==true - @@xml[:body] << "#{Ax[:tab]*5}\n#{Ax[:tab]*y}" + @per.body << "#{Ax[:tab]*5}\n#{Ax[:tab]*y}" @content_flag=false else - @@xml[:body] << "\n#{Ax[:tab]*y}" + @per.body << "\n#{Ax[:tab]*y}" end end end 3.downto(1) do |x| y=x - 1 - @@xml[:body] << "#{Ax[:tab]*y}" if @level[x]==true + @per.body << "#{Ax[:tab]*y}" if @level[x]==true end end def pre @@ -541,29 +546,28 @@ WOK encoding=if @sys.locale =~/utf-?8/i then '' else '' end - @@xml[:open] =< WOK - @@xml[:head] << '' - @@xml[:body] << '' + @per.head << '' + @per.body << '' end def post - @@xml[:head] << @@xml[:sc] - @@xml[:head] << '' - @@xml[:body] << '' - @@xml[:close] = '' + @per.head << @per.sc + @per.head << '' + @per.body << '' + @per.close << '' end def publish content=[] - content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] - content << @@xml[:owner_details] if @md.stmp =~/\w\w/ - content << @@xml[:tail] << @@xml[:close] + content << @per.open << @per.head << @per.body # << @per.metadata + content << @per.tail << @per.close content=content.flatten.compact Output.new(content,@md).xml - @@xml[:head],@@xml[:body],@@xml[:tail]=[],[],[] # check whether should be nil + @per.head,@per.body,@per.tail=[],[],[] # check whether should be nil end end class Output @@ -591,19 +595,21 @@ WOK if @prog.tidy !=false if (@md.opt.act[:verbose_plus][:set]==:on \ || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - 'invert', - 'Using XML Tidy', - 'check document structure' - ).colorize unless @md.opt.act[:quiet][:set]==:on - tell=SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - 'invert', - '', - '' - ) - tell.grey_open unless @md.opt.act[:quiet][:set]==:on + unless @md.opt.act[:quiet][:set]==:on + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + 'invert', + 'Using XML Tidy', + 'check document structure' + ).colorize + tell=SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + 'invert', + '', + '' + ) + tell.grey_open + end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags tidy=SiSU_Env::SystemCall.new(@file,tidyfile) tidy.well_formed? -- cgit v1.2.3