class SiSU_AO_DocumentStructureExtract::XML

Public Class Methods

new(md,data) click to toggle source
# File lib/sisu/ao_doc_str.rb, line 1915
def initialize(md,data)
  @data,@md=data,md
end

Public Instance Methods

dom() click to toggle source
# File lib/sisu/ao_doc_str.rb, line 1918
def dom
  @s=[ 'A', 'B', 'C', 'D', '1', '2', '3' ]
  tuned_file=structure_build
  tuned_file
end
puts_tag_close(lev,hs) click to toggle source
# File lib/sisu/ao_doc_str.rb, line 2251
def puts_tag_close(lev,hs)
  case hs[0]
  when 0
    #puts "#{spaces*0}</#{@s[0]}>" if (lev <= 0) and hs[0]
    puts "</#{@s[0]}>"         if (lev==0)
  when 1
    puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1]
    puts "</#{@s[0]}>"         if (lev==0)
  when 2
    puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2]
    puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1]
    puts "</#{@s[0]}>"         if (lev==0)
  when 3
    puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3]
    puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2]
    puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1]
    puts "</#{@s[0]}>"         if (lev==0)
  when 4
    puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
    puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3]
    puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2]
    puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1]
    puts "</#{@s[0]}>"         if (lev==0)
  when 5
    puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
    puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
    puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3]
    puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2]
    puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1]
    puts "</#{@s[0]}>"         if (lev==0)
  when 6
    puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6)
    puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
    puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
    puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) and hs[3]
    puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) and hs[2]
    puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) and hs[1]
    puts "</#{@s[0]}>"         if (lev==0)
  end
end
puts_tag_open(o,tag) click to toggle source
# File lib/sisu/ao_doc_str.rb, line 2248
def puts_tag_open(o,tag)
  puts %{#{spaces*o.ln}<#{tag[o.ln]} id="#{o.node}">}
end
spaces() click to toggle source
# File lib/sisu/ao_doc_str.rb, line 1923
def spaces
  Ax[:spaces]
end
structure_build() click to toggle source
# File lib/sisu/ao_doc_str.rb, line 1926
def structure_build
  data=@data
  tuned_file=[]
  hs=[0,false,false,false]
  t={
    lv: @s[0],
    status: :open,
  }
  tuned_file << tags(t)
  if @md.opt.act[:verbose_plus][:set]==:on
    puts "\nXML sisu structure outline --->\n"
    puts "<#{@s[0]}>"
  end
  data.each_with_index do |o,i|
    if o.is==:heading \
    || o.is==:heading_insert
      case o.ln
      when 0
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs=[0,true,false,false,false]
      when 1
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs=[1,true,true,false,false]
      when 2
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs=[2,true,true,true,false]
      when 3
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs=[3,true,true,true,true]
      when 4
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs[0]=4
      when 5
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs[0]=5
      when 6
        tuned_file << tag_close(o.ln,hs)
        tuned_file << tag_open(o,@s)
        if @md.opt.act[:verbose_plus][:set]==:on
          puts_tag_close(o.ln,hs)
          puts_tag_open(o,@s)
        end
        hs[0]=6
      end
    end
    tuned_file << o
  end
  if @md.opt.act[:verbose_plus][:set]==:on
    puts_tag_close(0,hs)
  end
  tuned_file << tag_close(0,hs)
  tuned_file=tuned_file.flatten
end
tag_close(lev,hs) click to toggle source
# File lib/sisu/ao_doc_str.rb, line 2039
def tag_close(lev,hs)
  ary=[]
  case hs[0]
  when 0
    if (lev <= 0) and hs[0]
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  when 1
    if (lev <= 1) and hs[1]
      t={
        lv: @s[1],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev==0)
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  when 2
    if (lev <= 2) and hs[2]
      t={
        lv: @s[2],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 1) and hs[1]
      t={
        lv: @s[1],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev==0)
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  when 3
    if (lev <= 3) and hs[3]
      t={
        lv: @s[3],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 2) and hs[2]
      t={
        lv: @s[2],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 1) and hs[1]
      t={
        lv: @s[1],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev==0)
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  when 4
    if (lev <= 4)
      t={
        lv: @s[4],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 3) and hs[3]
      t={
        lv: @s[3],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 2) and hs[2]
      t={
        lv: @s[2],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 1) and hs[1]
      t={
        lv: @s[1],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev==0)
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  when 5
    if (lev <= 5)
      t={
        lv: @s[5],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 4)
      t={
        lv: @s[4],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 3) and hs[3]
      t={
        lv: @s[3],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 2) and hs[2]
      t={
        lv: @s[2],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 1) and hs[1]
      t={
        lv: @s[1],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev==0)
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  when 6
    if (lev <= 6)
      t={
        lv: @s[6],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 5)
      t={
        lv: @s[5],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 4)
      t={
        lv: @s[4],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 3) and hs[3]
      t={
        lv: @s[3],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 2) and hs[2]
      t={
        lv: @s[2],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev <= 1) and hs[1]
      t={
        lv: @s[1],
        status: :close,
      }
      ary << tags(t)
    end
    if (lev==0)
      t={
        lv: @s[0],
        status: :close,
      }
      ary << tags(t)
    end
  end
  ary
end
tag_open(o,tag) click to toggle source
# File lib/sisu/ao_doc_str.rb, line 2034
def tag_open(o,tag)
  t={ lv: tag[o.ln], node: o.node, status: :open }
  t_o=tags(t)
  t_o
end
tags(o) click to toggle source
# File lib/sisu/ao_doc_str.rb, line 2009
def tags(o)
  tag=(o[:status]==:open) \
  ? %{<#{o[:lv]} id="#{o[:node]}">}
  : "</#{o[:lv]}>"
  ln=case o[:lv]
  when 'A' then 0
  when 'B' then 1
  when 'C' then 2
  when 'D' then 3
  when '1' then 4
  when '2' then 5
  when '3' then 6
  when '4' then 7
  when '5' then 8
  when '6' then 9
  end
  h={
    tag: tag,
    node: o[:node],
    lv: o[:lv],
    ln: ln,
    status: o[:status],
  }
  SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments
end