Class: Metanorma::Plateau::Converter
- Inherits:
-
Jis::Converter
- Object
- Jis::Converter
- Metanorma::Plateau::Converter
- Defined in:
- lib/metanorma/plateau/cleanup.rb,
lib/metanorma/plateau/converter.rb
Constant Summary collapse
- XML_ROOT_TAG =
"plateau-standard".freeze
- XML_NAMESPACE =
"https://www.metanorma.org/ns/plateau".freeze
Instance Method Summary collapse
-
#biblio_reorder(xmldoc) ⇒ Object
Abandoned in favour of JIS ordering def pub_class(bib) return 1 if bib.at(“#PUBLISHER[name = ‘#'en'’]”) || bib.at(“#PUBLISHER[name = ‘#'ja'’]”) || bib.at(“#PUBLISHER[abbreviation = ‘MLIT’]”) return 2 if bib == “standard”.
- #blocksource_cleanup(xmldoc) ⇒ Object
- #boilerplate_file(_x_orig) ⇒ Object
- #default_publisher ⇒ Object
- #default_requirement_model ⇒ Object
- #doctype_validate(_xmldoc) ⇒ Object
- #html_converter(node) ⇒ Object
- #init_misc(node) ⇒ Object
-
#iso_id(node, xml) ⇒ Object
do not use pubid.
- #metadata_id(node, xml) ⇒ Object
- #metadata_stage(node, xml) ⇒ Object
-
#metadata_status(node, xml) ⇒ Object
do not use pubid.
- #org_abbrev ⇒ Object
- #pdf_converter(node) ⇒ Object
- #presentation_xml_converter(node) ⇒ Object
-
#pub_hash ⇒ Object
Plateau reuse of the JIS publisher default setting.
- #schema_file ⇒ Object
Instance Method Details
#biblio_reorder(xmldoc) ⇒ Object
Abandoned in favour of JIS ordering
def pub_class(bib)
return 1 if bib.at("#{PUBLISHER}[name = '#{pub_hash['en']}']") ||
bib.at("#{PUBLISHER}[name = '#{pub_hash['ja']}']") ||
bib.at("#{PUBLISHER}[abbreviation = 'MLIT']")
return 2 if bib["type"] == "standard"
3
end
25 26 27 28 29 |
# File 'lib/metanorma/plateau/cleanup.rb', line 25 def biblio_reorder(xmldoc) xmldoc.xpath("//references").each do |r| biblio_reorder1(r) end end |
#blocksource_cleanup(xmldoc) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/metanorma/plateau/cleanup.rb', line 4 def blocksource_cleanup(xmldoc) xmldoc.xpath("//termsource").each do |s| p = s.previous_element or next %w[p ol ul dl].include? p.name or next s.name = "source" s.delete("type") s.parent = p end super end |
#boilerplate_file(_x_orig) ⇒ Object
28 29 30 |
# File 'lib/metanorma/plateau/converter.rb', line 28 def boilerplate_file(_x_orig) nil end |
#default_publisher ⇒ Object
24 25 26 |
# File 'lib/metanorma/plateau/converter.rb', line 24 def default_publisher "MLIT" end |
#default_requirement_model ⇒ Object
12 13 14 |
# File 'lib/metanorma/plateau/converter.rb', line 12 def default_requirement_model "ogc" end |
#doctype_validate(_xmldoc) ⇒ Object
43 44 45 46 47 |
# File 'lib/metanorma/plateau/converter.rb', line 43 def doctype_validate(_xmldoc) %w(handbook technical-report annex).include? @doctype or @log.add("Document Attributes", nil, "#{@doctype} is not a recognised document type") end |
#html_converter(node) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/metanorma/plateau/converter.rb', line 75 def html_converter(node) if node.nil? IsoDoc::Plateau::HtmlConvert.new({}) else IsoDoc::Plateau::HtmlConvert.new(html_extract_attributes(node)) end end |
#init_misc(node) ⇒ Object
32 33 34 35 |
# File 'lib/metanorma/plateau/converter.rb', line 32 def init_misc(node) super @default_doctype = "technical-report" end |
#iso_id(node, xml) ⇒ Object
do not use pubid
58 59 60 61 62 |
# File 'lib/metanorma/plateau/converter.rb', line 58 def iso_id(node, xml) id = node.attr("docnumber") or return xml.docidentifier "PLATEAU #{id.sub(/^PLATEAU /, '')}", **attr_code(type: "PLATEAU", primary: "true") end |
#metadata_id(node, xml) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/metanorma/plateau/converter.rb', line 49 def (node, xml) if id = node.attr("docidentifier") xml.docidentifier "PLATEAU #{id.sub(/^PLATEAU /, '')}", **attr_code(type: "PLATEAU", primary: "true") else iso_id(node, xml) end end |
#metadata_stage(node, xml) ⇒ Object
73 |
# File 'lib/metanorma/plateau/converter.rb', line 73 def (node, xml); end |
#metadata_status(node, xml) ⇒ Object
do not use pubid
65 66 67 68 69 70 71 |
# File 'lib/metanorma/plateau/converter.rb', line 65 def (node, xml) stage = get_stage(node) xml.status do |s| s.stage stage i = node.attr("iteration") and s.iteration i end end |
#org_abbrev ⇒ Object
20 21 22 |
# File 'lib/metanorma/plateau/converter.rb', line 20 def org_abbrev super.merge(pub_hash["en"] => "MLIT") end |
#pdf_converter(node) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/metanorma/plateau/converter.rb', line 83 def pdf_converter(node) return if node.attr("no-pdf") if node.nil? IsoDoc::Plateau::PdfConvert.new({}) else IsoDoc::Plateau::PdfConvert.new(pdf_extract_attributes(node)) end end |
#presentation_xml_converter(node) ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/metanorma/plateau/converter.rb', line 93 def presentation_xml_converter(node) if node.nil? IsoDoc::Plateau::PresentationXMLConvert.new({}) else IsoDoc::Plateau::PresentationXMLConvert .new(doc_extract_attributes(node) .merge(output_formats: ::Metanorma::Plateau::Processor.new .output_formats)) end end |
#pub_hash ⇒ Object
Plateau reuse of the JIS publisher default setting
38 39 40 41 |
# File 'lib/metanorma/plateau/converter.rb', line 38 def pub_hash { "ja" => "国土交通省", "en" => "Ministry of Land, Infrastructure, Transport and Tourism" } end |
#schema_file ⇒ Object
16 17 18 |
# File 'lib/metanorma/plateau/converter.rb', line 16 def schema_file "plateau.rng" end |