aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/current/xml_dom.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/current/xml_dom.rb')
-rw-r--r--lib/sisu/current/xml_dom.rb134
1 files changed, 70 insertions, 64 deletions
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] <<<<WOK
+ @per.body <<<<WOK
#{Ax[:tab]*n}#{xml_el}
#{Ax[:tab]*n1}<heading>
#{Ax[:tab]*n2}<object id="#{dob.ocn}">
@@ -262,26 +267,26 @@ WOK
if @cont[1] \
or @cont[2] \
or @cont[3]
- @@xml[:body] << "#{Ax[:tab]*5}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
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}</contents#{v}>" }
+ [4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=@copen[4]=false
elsif @copen[3] # 3~
- [3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
elsif @copen[2] # 2~
- [2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
elsif @copen[1] # 1~
- [1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
@copen[1]=@copen[2]=@copen[3]=false
end
- @@xml[:body] << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]
+ @per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]
@level[x]=false
end
when 4..7
@@ -295,29 +300,29 @@ WOK
xml_content="\n#{Ax[:tab]*5}<content>"
case lv
when 4
- @@xml[:body] << "#{Ax[:tab]*5}</content>" if @cont[1]
+ @per.body << "#{Ax[:tab]*5}</content>" if @cont[1]
if @copen[4]==true # 4~
- [4,3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3]==true # 3~
- [3,2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3,2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[2]==true # 2~
- [2,1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [2,1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[1]==true # 1~
- [1].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [1].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
end
@cont[1]=true
when 5
if @cont[3] \
or @cont[2] \
or @cont[1]
- @@xml[:body] << "#{Ax[:tab]*5}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4]==true #4~
- [4,3,2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3,2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3]==true #3~
- [3,2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3,2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[2]==true #2~
- [2].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [2].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
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}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4] #4~
- [4,3].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4,3].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
elsif @copen[3] #3~
- [3].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [3].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
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}</content>"
+ @per.body << "#{Ax[:tab]*5}</content>"
end
if @copen[4] #4~
- [4].each { |v| @@xml[:body] << "#{Ax[:tab]*n}</contents#{v}>" }
+ [4].each { |v| @per.body << "#{Ax[:tab]*n}</contents#{v}>" }
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}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>} if defined? dob.ocn
+ @per.body << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
+ @per.body << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>} if defined? dob.ocn
end
- #@@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>}
- #@@xml[:body] << %{#{Ax[:tab]*7}<text class="#{dob.is}">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}</text>}
- @@xml[:body] << %{#{Ax[:tab]*6}</object>}
+ #@per.body << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>}
+ #@per.body << %{#{Ax[:tab]*7}<text class="#{dob.is}">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*7}<text class="#{type}">#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
+ @per.body << %{#{Ax[:tab]*7}</text>}
+ @per.body << %{#{Ax[:tab]*6}</object>}
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}</content>\n#{Ax[:tab]*y}</contents#{v}>"
+ @per.body << "#{Ax[:tab]*5}</content>\n#{Ax[:tab]*y}</contents#{v}>"
@content_flag=false
else
- @@xml[:body] << "\n#{Ax[:tab]*y}</contents#{v}>"
+ @per.body << "\n#{Ax[:tab]*y}</contents#{v}>"
end
end
end
3.downto(1) do |x|
y=x - 1
- @@xml[:body] << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
+ @per.body << "#{Ax[:tab]*y}</heading#{x}>" if @level[x]==true
end
end
def pre
@@ -541,29 +546,28 @@ WOK
encoding=if @sys.locale =~/utf-?8/i then '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
- @@xml[:open] =<<WOK
+ @per.open =<<WOK
#{encoding}
#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
- @@xml[:head] << '<head>'
- @@xml[:body] << '<body>'
+ @per.head << '<head>'
+ @per.body << '<body>'
end
def post
- @@xml[:head] << @@xml[:sc]
- @@xml[:head] << '</head>'
- @@xml[:body] << '</body>'
- @@xml[:close] = '</document>'
+ @per.head << @per.sc
+ @per.head << '</head>'
+ @per.body << '</body>'
+ @per.close << '</document>'
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?