class IsoDoc::ITU::PresentationXMLConvert

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/isodoc/itu/presentation_xml_convert.rb, line 8
def initialize(options)
  @hierarchical_assets = options[:hierarchical_assets]
  super
end

Public Instance Methods

amendment_id(bib) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 135
def amendment_id(bib)
  %w(amendment corrigendum).each do |w|
    if dn = bib.at(ns("./ext/structuredidentifier/#{w}"))
      dn["language"] = ""
      dn.next = dn.dup
      dn.next["language"] = @lang
      dn.next.children = @i18n.l10n("#{@i18n.get[w]} #{dn&.text}")
    end
  end
end
annex1(elem) click to toggle source
Calls superclass method
# File lib/isodoc/itu/presentation_xml_convert.rb, line 163
def annex1(elem)
  return super unless elem&.at(ns("//bibdata/ext/doctype"))&.text ==
    "resolution"

  lbl = @xrefs.anchor(elem["id"], :label)
  subhead = (@i18n.l10n("(#{@i18n.get['to']} ") +
             elem.at(ns("//bibdata/title[@type = 'resolution']"))
               .children.to_xml + @i18n.l10n(")"))
  elem.elements.first.previous =
    "<p class='supertitle'>#{lbl}<br/>#{subhead}</p>"
  t = elem.at(ns("./title")) and
    t.children = "<strong>#{t.children.to_xml}</strong>"
end
bibdata_dates(bib) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 67
def bibdata_dates(bib)
  bib.xpath(ns("./date")).each do |d|
    d.next = d.dup
    d.next["format"] = "ddMMMyyyy"
    d.next.children = ddMMMyyyy(d.text)
  end
end
bibdata_i18n(bib) click to toggle source
Calls superclass method
# File lib/isodoc/itu/presentation_xml_convert.rb, line 60
def bibdata_i18n(bib)
  super
  bibdata_dates(bib)
  bibdata_title(bib)
  amendment_id(bib)
end
bibdata_title(bib) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 75
def bibdata_title(bib)
  case bib&.at(ns("./ext/doctype"))&.text
  when "service-publication" then bibdata_title_service_population(bib)
  when "resolution" then bibdata_title_resolution(bib)
  end
end
bibdata_title_resolution(bib) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 82
      def bibdata_title_resolution(bib)
        place = bib&.at(ns("./ext/meeting-place"))&.text
        ed = bib&.at(ns("./edition"))&.text
        rev = ed && ed != "1" ? "#{@i18n.get['revision_abbreviation']} " : ""
        year = bib&.at(ns("./ext/meeting-date/from | ./ext/meeting-date/on"))
          &.text&.gsub(/-.*$/, "")
        num = bib&.at(ns("./docnumber"))&.text
        text = @i18n.l10n("#{@i18n.get['doctype_dict']['resolution'].upcase} "\
                          "#{num} (#{rev}#{place}, #{year})")
        ins = bib.at(ns("./title"))
        ins.next = <<~INS
          <title language="#{@lang}" format="text/plain" type="resolution">#{text}</title>
          <title language="#{@lang}" format="text/plain" type="resolution-placedate">#{place}, #{year}</title>
        INS
      end
bibdata_title_service_population(bib) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 98
      def bibdata_title_service_population(bib)
        date = bib&.at(ns("./date[@type = 'published']"))&.text or return
        text = l10n(@i18n.get["position_on"].sub(/%/, ddmmmmyyyy(date)))
        ins = bib.at(ns("./title"))
        ins.next = <<~INS
          <title language="#{@lang}" format="text/plain" type="position-sp">#{text}</title>
        INS
      end
clause1(elem) click to toggle source
Calls superclass method
# File lib/isodoc/itu/presentation_xml_convert.rb, line 150
def clause1(elem)
  return super unless elem&.at(ns("//bibdata/ext/doctype"))&.text ==
    "resolution"
  return super unless %w(sections bibliography).include? elem.parent.name
  return if @suppressheadingnumbers || elem["unnumbered"]

  t = elem.at(ns("./title")) and t["depth"] = "1"
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
  elem.elements.first.previous =
    "<p keep-with-next='true' class='supertitle'>"\
    "#{@i18n.get['section'].upcase} #{lbl}</p>"
end
ddMMMyyyy(date) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 107
def ddMMMyyyy(date)
  d = date.split("-").map { |x| x.sub(/^0/, "") }
  case @lang
  when "zh"
    d[0] += "年" if d[0]
    d[1] += "月" if d[1]
    d[2] += "日" if d[2]
    d.join
  when "ar"
    d[1] = ::RomanNumerals.to_roman(d[1].to_i).upcase if d[1]
    d.join(".")
  else
    d[1] = ::RomanNumerals.to_roman(d[1].to_i).upcase if d[1]
    d.reverse.join(".")
  end
end
ddmmmmyyyy(date) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 124
def ddmmmmyyyy(date)
  if @lang == "zh"
    ddMMMyyyy(date)
  else
    d = date.split("-")
    d[1] = @meta.months[d[1].to_sym] if d[1]
    d[2] = d[2].sub(/^0/, "") if d[2]
    l10n(d.reverse.join(" "))
  end
end
eref(docxml) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 17
def eref(docxml)
  docxml.xpath(ns("//eref")).each do |f|
    eref1(f)
  end
end
eref1(elem) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 35
def eref1(elem)
  get_eref_linkend(elem)
end
get_eref_linkend(node) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 45
def get_eref_linkend(node)
  contents = non_locality_elems(node).select do |c|
    !c.text? || /\S/.match(c)
  end
  return unless contents.empty?

  link = anchor_linkend(node,
                        docid_l10n(node["target"] || node["citeas"]))
  link && !/^\[.*\]$/.match(link) and link = "[#{link}]"
  link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
                          link, node)
  non_locality_elems(node).each(&:remove)
  node.add_child(link)
end
note1(elem) click to toggle source
Calls superclass method
# File lib/isodoc/itu/presentation_xml_convert.rb, line 39
def note1(elem)
  return if elem["type"] == "title-footnote"

  super
end
origin(docxml) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 23
def origin(docxml)
  docxml.xpath(ns("//origin[not(termref)]")).each do |f|
    eref1(f)
  end
end
prefix_container(container, linkend, _target) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 13
def prefix_container(container, linkend, _target)
  l10n("#{linkend} #{@i18n.get['in']} #{@xrefs.anchor(container, :xref)}")
end
quotesource(docxml) click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 29
def quotesource(docxml)
  docxml.xpath(ns("//quote/source")).each do |f|
    eref1(f)
  end
end
twitter_cldr_localiser_symbols() click to toggle source
# File lib/isodoc/itu/presentation_xml_convert.rb, line 146
def twitter_cldr_localiser_symbols
  { group: "'" }
end