aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/xml_dom.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/xml_dom.rb')
-rw-r--r--lib/sisu/v3/xml_dom.rb107
1 files changed, 52 insertions, 55 deletions
diff --git a/lib/sisu/v3/xml_dom.rb b/lib/sisu/v3/xml_dom.rb
index 53c60bf8..6b8c4e5c 100644
--- a/lib/sisu/v3/xml_dom.rb
+++ b/lib/sisu/v3/xml_dom.rb
@@ -62,9 +62,9 @@ module SiSU_XML_DOM
include SiSU_Env
require_relative 'dal' # dal.rb
require_relative 'shared_xml' # shared_xml.rb
- include SiSU_XML_munge
+ include SiSU_XML_Munge
require_relative 'xml_format' # xml_format.rb
- include SiSU_XML_format
+ include SiSU_XML_Format
require_relative 'rexml' # rexml.rb
include SiSU_Rexml
require_relative 'shared_metadata' # shared_metadata.rb
@@ -73,7 +73,7 @@ module SiSU_XML_DOM
class Source
def initialize(opt)
@opt=opt
- @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt)
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def read
begin
@@ -91,7 +91,7 @@ module SiSU_XML_DOM
SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"file://#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}").flow if @opt.cmd =~/[MV]/
end
SiSU_XML_DOM::Source::Songsheet.new(@particulars).songsheet
- rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error
ensure
end
end
@@ -99,28 +99,28 @@ module SiSU_XML_DOM
class Songsheet
def initialize(particulars)
@env,@md,@dal_array,@particulars=particulars.env,particulars.md,particulars.dal_array,particulars
- @file=SiSU_Env::SiSU_file.new(@md)
+ @file=SiSU_Env::FileOp.new(@md)
end
def songsheet
begin
SiSU_XML_DOM::Source::Scroll.new(@particulars).songsheet
SiSU_XML_DOM::Source::Tidy.new(@md,@file.place_file.xml_dom.dir).xml if @md.opt.cmd =~/[vVM]/ # test wellformedness, comment out when not in use
SiSU_Rexml::Rexml.new(@md,@file.place_file.xml_dom.dir).xml if @md.opt.cmd =~/M/ # test rexml parsing, comment out when not in use #debug
- rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error
+ rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error
ensure
end
end
end
class Scroll
require_relative 'shared_txt' # shared_txt.rb
- include SiSU_text_utils
+ include SiSU_TextUtils
require_relative 'shared_xhtml' # decide use, whether xml rather than xhtml
@@xml={ body: [], open: [], close: [], head: [], sc: [] }
def initialize(particulars)
@env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array
- @vz=SiSU_Env::Get_init.instance.skin
- @trans=SiSU_XML_munge::Trans.new(@md)
- @sys=SiSU_Env::System_call.new
+ @vz=SiSU_Env::GetInit.instance.skin
+ @trans=SiSU_XML_Munge::Trans.new(@md)
+ @sys=SiSU_Env::SystemCall.new
end
def songsheet
pre
@@ -130,15 +130,15 @@ module SiSU_XML_DOM
end
protected
def xml_markup(dob='')
- dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,
- '<endnote><number>\1</number><note>\2</note></endnote> ')
- dob.obj.gsub!(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/,
- '<endnote><symbol>\1</symbol><note>\2</note></endnote> ')
- dob.obj.gsub!(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,
- '<endnote><symbol>\1</symbol><note>\2</note></endnote> ')
+ dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,
+ '<endnote><number>\1</number><note>\2</note></endnote> ').
+ gsub(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/,
+ '<endnote><symbol>\1</symbol><note>\2</note></endnote> ').
+ gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,
+ '<endnote><symbol>\1</symbol><note>\2</note></endnote> ')
end
def xml_head
- metadata=Metadata::Summary.new(@md).xml_dom.metadata
+ metadata=SiSU_Metadata::Summary.new(@md).xml_dom.metadata
@@xml[:head] << metadata
end
def xml_sc(md='')
@@ -165,7 +165,7 @@ WOK
end
def xml_element(dob,xml_el='',xml_content='',type='norm')
n=n1=n2=n3=0
- if dob.is=='heading'
+ if dob.is==:heading
lv=dob.ln
n=dob.ln - 1
n1=dob.ln
@@ -200,7 +200,7 @@ WOK
end
def xml_structure(dob,type='norm')
n=n1=n2=n3=0
- if dob.is=='heading'
+ if dob.is==:heading
lv=dob.ln
n=dob.ln - 1
n1=dob.ln
@@ -309,31 +309,28 @@ WOK
end
def block_structure(dob)
dob=@trans.markup_block(dob) #decide check & FIX
- dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,
- '<endnote><number>\1</number><note>\2</note></endnote> ')
- dob.obj.strip!
+ dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,
+ '<endnote><number>\1</number><note>\2</note></endnote> ').strip
dob
end
def group_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
- dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,
- '<endnote><number>\1</number><note>\2</note></endnote> ')
- dob.obj.strip!
+ dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m,
+ '<endnote><number>\1</number><note>\2</note></endnote> ').strip
dob
end
def poem_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
- dob.obj.strip!
+ dob.obj=dob.obj.strip
dob
end
def code_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
- dob.obj.gsub!(/\s\s/,'&#160;&#160;')
- dob.obj.strip!
+ dob.obj=dob.obj.gsub(/\s\s/,'&#160;&#160;').strip
dob
end
def table_structure(dob) #tables
- table=SiSU_XHTML_shared::Table_xhtml.new(dob)
+ table=SiSU_XHTML_Shared::TableXHTML.new(dob)
end
def markup(data)
xml_sc(@md)
@@ -347,18 +344,18 @@ WOK
@trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8
dob=@trans.markup(dob)
if @rcdc==false \
- and (dob.is =~/^meta/ \
+ and (dob.is ==:meta \
and dob.obj =~/Document Information/)
@rcdc=true
end
if dob !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
- @p_num=SiSU_XML_format::Paragraph_number.new(@md,dob.ocn) if defined? dob.ocn
+ @p_num=SiSU_XML_Format::ParagraphNumber.new(@md,dob.ocn) if defined? dob.ocn
if not @rcdc
if defined? dob.ocn \
and dob.ocn.to_s =~/\d+/
- format_scroll=SiSU_XML_format::Format_scroll.new(@md,dob) if dob.is=='para' and dob.indent ##FIX
- x=SiSU_XML_format::Format_seg.new(@md,dob)
- if dob.is=='heading'
+ format_scroll=SiSU_XML_Format::FormatScroll.new(@md,dob) if dob.is==:para and dob.indent ##FIX
+ x=SiSU_XML_Format::FormatSeg.new(@md,dob)
+ if dob.is==:heading
if dob.ln==1
type="heading_section_#{dob.ln.to_s}"
xml_markup(dob)
@@ -391,32 +388,32 @@ WOK
end
else
ocn=dob.ocn
- if dob.is=='verse'
+ if dob.is==:verse
type='verse'
poem_structure(dob) #redo
- elsif dob.is=='group'
+ elsif dob.is==:group
type='group'
group_structure(dob) #redo
- elsif dob.is=='block'
+ elsif dob.is==:block
type='block'
block_structure(dob) #redo
- elsif dob.is=='code'
+ elsif dob.is==:code
type='code'
code_structure(dob) #redo
- elsif dob.is=='table' # tables come as single block #work area 2005w13
+ elsif dob.is==:table # tables come as single block #work area 2005w13
type='table'
table_structure(dob)
- elsif dob.is=='para' \
+ elsif dob.is==:para \
and dob.indent.to_s =~/[1-9]/ \
and dob.bullet_
type="indent_bullet#{dob.indent.to_s}"
xml_markup(dob)
- elsif dob.is=='para' \
+ elsif dob.is==:para \
and dob.indent.to_s =~/[1-9]/ \
and dob.indent == dob.hang
type="indent#{dob.indent.to_s}"
xml_markup(dob)
- elsif dob.is=='para' \
+ elsif dob.is==:para \
and dob.hang.to_s =~/[0-9]/ \
and dob.indent != dob.hang
type="hang#{dob.hang.to_s}_indent#{dob.indent.to_s}"
@@ -430,7 +427,7 @@ WOK
elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
elsif dob.obj =~/(MetaData)/
txt_obj={ txt: '<br /><a name="metadata">MetaData</a>' }
- format_scroll=Format_scroll.new(@md,txt_obj)
+ format_scroll=FormatScroll.new(@md,txt_obj)
dob.obj=format_scroll.bold_para
elsif dob.obj =~/(Owner Details)/
dob.obj=''
@@ -442,7 +439,7 @@ WOK
if dob.obj =~/.*<:#>.*$/
dob.obj=if dob.obj =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/
txt_obj={ txt: dob.obj }
- format_text=Format_text_object.new(@md,txt_obj)
+ format_text=FormatTextObject.new(@md,txt_obj)
format_text.scr_inden_ocn_e_no_paranum
end
end
@@ -450,7 +447,7 @@ WOK
end
else #
end
- dob.obj.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj
+ dob.obj=dob.obj.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if dob.obj
end
end
@content_flag=true
@@ -471,15 +468,15 @@ WOK
end
end
def pre
- rdf=SiSU_XML_tags::RDF.new(@md)
- dir=SiSU_Env::Info_env.new
- css=SiSU_Env::CSS_stylesheet.new(@md)
+ rdf=SiSU_XML_Tags::RDF.new(@md)
+ dir=SiSU_Env::InfoEnv.new
+ stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_dom').stylesheet
encoding=if @sys.locale =~/utf-?8/i; '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
else '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>'
end
@@xml[:open] =<<WOK
#{encoding}
-#{css.xml_dom}
+#{stylesheet.css_head_xml}
#{rdf.comment_xml}
<document>
WOK
@@ -497,7 +494,7 @@ WOK
content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata]
content << @@xml[:owner_details] if @md.stmp =~/\w\w/
content << @@xml[:tail] << @@xml[:close]
- content.flatten!.compact!
+ content=content.flatten.compact
Output.new(content,@md).xml
@@xml[:head],@@xml[:body],@@xml[:tail]=[],[],[] # check whether should be nil
end
@@ -506,13 +503,13 @@ WOK
include SiSU_Param
def initialize(data,md)
@data,@md=data,md
- @file=SiSU_Env::SiSU_file.new(@md)
+ @file=SiSU_Env::FileOp.new(@md)
end
def xml
- SiSU_Env::SiSU_file.new(@md).mkdir
+ SiSU_Env::FileOp.new(@md).mkdir
filename_xml=@file.write_file.xml_dom
@data.each do |str|
- str.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'')
+ str=str.gsub(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'')
filename_xml.puts str unless str.empty?
end
filename_xml.close
@@ -521,7 +518,7 @@ WOK
class Tidy
def initialize(md,file)
@md,@file=md,file
- @prog=SiSU_Env::Info_program.new
+ @prog=SiSU_Env::InfoProgram.new
end
def xml
if @prog.tidy !=false
@@ -530,7 +527,7 @@ WOK
tell=SiSU_Screen::Ansi.new(@md.opt.cmd,'invert','','')
tell.grey_open unless @md.opt.cmd =~/q/
tidyfile='/dev/null' #don't want one or screen output, check for alternative flags
- tidy=SiSU_Env::System_call.new(@file,tidyfile)
+ tidy=SiSU_Env::SystemCall.new(@file,tidyfile)
tidy.well_formed?
tell.p_off unless @md.opt.cmd =~/q/
end