From 5803430358cff957f500fa2dcf1e290eae95a748 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 23 Nov 2014 01:01:27 -0500 Subject: d: xmls, reorganize, introduce new file --- lib/sisu/develop/xml_dom.rb | 94 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'lib/sisu/develop/xml_dom.rb') diff --git a/lib/sisu/develop/xml_dom.rb b/lib/sisu/develop/xml_dom.rb index 3664820d..b3d3adde 100644 --- a/lib/sisu/develop/xml_dom.rb +++ b/lib/sisu/develop/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,12 +159,12 @@ 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 @@ -182,7 +183,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 +205,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 +222,7 @@ WOK else '' end xml_el ||='' - @@xml[:body] <<< #{Ax[:tab]*n2} @@ -262,26 +263,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 +296,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 +326,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 +339,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 +358,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 +524,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 +542,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 -- cgit v1.2.3