Class: Metanorma::Plateau::Converter

Inherits:
Jis::Converter
  • Object
show all
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

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

#default_publisherObject



26
27
28
# File 'lib/metanorma/plateau/converter.rb', line 26

def default_publisher
  "MLIT"
end

#default_requirement_modelObject



12
13
14
# File 'lib/metanorma/plateau/converter.rb', line 12

def default_requirement_model
  "ogc"
end

#doctype_validate(_xmldoc) ⇒ Object



41
42
43
44
45
# File 'lib/metanorma/plateau/converter.rb', line 41

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



73
74
75
76
77
78
79
# File 'lib/metanorma/plateau/converter.rb', line 73

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



30
31
32
33
# File 'lib/metanorma/plateau/converter.rb', line 30

def init_misc(node)
  super
  @default_doctype = "technical-report"
end

#iso_id(node, xml) ⇒ Object

do not use pubid



56
57
58
59
60
# File 'lib/metanorma/plateau/converter.rb', line 56

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



47
48
49
50
51
52
53
# File 'lib/metanorma/plateau/converter.rb', line 47

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



71
# File 'lib/metanorma/plateau/converter.rb', line 71

def (node, xml); end

#metadata_status(node, xml) ⇒ Object

do not use pubid



63
64
65
66
67
68
69
# File 'lib/metanorma/plateau/converter.rb', line 63

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_abbrevObject



22
23
24
# File 'lib/metanorma/plateau/converter.rb', line 22

def org_abbrev
  super.merge(pub_hash["en"] => "MLIT")
end

#pdf_converter(node) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/metanorma/plateau/converter.rb', line 81

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



91
92
93
94
95
96
97
98
99
100
# File 'lib/metanorma/plateau/converter.rb', line 91

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_hashObject

Plateau reuse of the JIS publisher default setting



36
37
38
39
# File 'lib/metanorma/plateau/converter.rb', line 36

def pub_hash
  { "ja" => "国土交通省",
    "en" => "Ministry of Land, Infrastructure, Transport and Tourism" }
end

#validate(doc) ⇒ Object



16
17
18
19
20
# File 'lib/metanorma/plateau/converter.rb', line 16

def validate(doc)
  content_validate(doc)
  schema_validate(formattedstr_strip(doc.dup),
                  File.join(File.dirname(__FILE__), "plateau.rng"))
end