require_relative "init" require "roman-numerals" require "isodoc" module IsoDoc module ITU class PresentationXMLConvert < IsoDoc::PresentationXMLConvert def initialize(options) @hierarchical_assets = options[:hierarchical_assets] super end def prefix_container(container, linkend, _target) l10n("#{linkend} #{@i18n.get["in"]} #{@xrefs.anchor(container, :xref)}") end def eref(docxml) docxml.xpath(ns("//eref")).each do |f| eref1(f) end end def origin(docxml) docxml.xpath(ns("//origin[not(termref)]")).each do |f| eref1(f) end end def quotesource(docxml) docxml.xpath(ns("//quote/source")).each do |f| eref1(f) end end def eref1(f) get_eref_linkend(f) end def note1(f) return if f["type"] == "title-footnote" super end 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 { |n| n.remove } node.add_child(link) end def bibdata_i18n(b) super bibdata_dates(b) bibdata_title(b) amendment_id(b) end def bibdata_dates(b) b.xpath(ns("./date")).each do |d| d.next = d.dup d.next["format"] = "ddMMMyyyy" d.next.children = ddMMMyyyy(d.text) end end def bibdata_title(b) case b&.at(ns("./ext/doctype"))&.text when "service-publication" then bibdata_title_service_population(b) when "resolution" then bibdata_title_resolution(b) end end def bibdata_title_resolution(b) num = b&.at(ns("./docnumber"))&.text place = b&.at(ns("./ext/meeting-place"))&.text ed = b&.at(ns("./edition"))&.text rev = (ed && ed != "1") ? "#{@i18n.get["revision_abbreviation"]} " : "" year = b&.at(ns("./ext/meeting-date/from | ./ext/meeting-date/on"))&.text&.gsub(/-.*$/, "") num = b&.at(ns("./docnumber"))&.text text = @i18n.l10n("#{@i18n.get['doctype_dict']['resolution'].upcase} #{num} (#{rev}#{place}, #{year})") ins = b.at(ns("./title")) ins.next = <<~END
#{@i18n.get['section'].upcase} #{lbl}
" end def annex1(f) return super unless f&.at(ns("//bibdata/ext/doctype"))&.text == "resolution" lbl = @xrefs.anchor(f['id'], :label) subhead = (@i18n.l10n("(#{@i18n.get['to']} ") + f.at(ns("//bibdata/title[@type = 'resolution']")).children.to_xml + @i18n.l10n(")")) f.elements.first.previous = "#{lbl}
#{subhead}