Class: Metanorma::JIS::Converter
- Inherits:
-
ISO::Converter
- Object
- ISO::Converter
- Metanorma::JIS::Converter
- Defined in:
- lib/metanorma/jis/front.rb,
lib/metanorma/jis/converter.rb
Constant Summary collapse
- XML_ROOT_TAG =
"jis-standard".freeze
- XML_NAMESPACE =
"https://www.metanorma.org/ns/jis".freeze
Instance Method Summary collapse
- #boilerplate_file(_x_orig) ⇒ Object
- #doc_converter(node) ⇒ Object
- #html_converter(node) ⇒ Object
- #init_i18n(node) ⇒ Object
- #metadata_author(node, xml) ⇒ Object
- #metadata_copyright(node, xml) ⇒ Object
- #metadata_publisher(node, xml) ⇒ Object
- #org_abbrev ⇒ Object
- #pdf_converter(node) ⇒ Object
- #presentation_xml_converter(node) ⇒ Object
- #script_validate(xmldoc) ⇒ Object
- #validate(doc) ⇒ Object
Instance Method Details
#boilerplate_file(_x_orig) ⇒ Object
18 19 20 |
# File 'lib/metanorma/jis/converter.rb', line 18 def boilerplate_file(_x_orig) File.join(@libdir, "jis_intro_jp.xml") end |
#doc_converter(node) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/metanorma/jis/converter.rb', line 30 def doc_converter(node) if node.nil? IsoDoc::JIS::WordConvert.new({}) else IsoDoc::JIS::WordConvert.new(doc_extract_attributes(node)) end end |
#html_converter(node) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/metanorma/jis/converter.rb', line 22 def html_converter(node) if node.nil? IsoDoc::JIS::HtmlConvert.new({}) else IsoDoc::JIS::HtmlConvert.new(html_extract_attributes(node)) end end |
#init_i18n(node) ⇒ Object
13 14 15 16 |
# File 'lib/metanorma/jis/converter.rb', line 13 def init_i18n(node) node.attr("language") or node.set_attr("language", "ja") super end |
#metadata_author(node, xml) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/metanorma/jis/front.rb', line 8 def (node, xml) publishers = node.attr("publisher") || "JIS" csv_split(publishers)&.each do |p| xml.contributor do |c| c.role type: "author" c.organization do |a| organization(a, p, false, node, !node.attr("publisher")) end end end node.attr("doctype") == "expert-commentary" and (node, xml) end |
#metadata_copyright(node, xml) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/metanorma/jis/front.rb', line 34 def (node, xml) pub = node.attr("copyright-holder") || node.attr("publisher") || "JIS" csv_split(pub)&.each do |p| xml.copyright do |c| c.from (node.attr("copyright-year") || Date.today.year) c.owner do |owner| owner.organization do |o| organization(o, p, true, node, !node.attr("copyright-holder") || node.attr("publisher")) end end end end end |
#metadata_publisher(node, xml) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/metanorma/jis/front.rb', line 22 def (node, xml) publishers = node.attr("publisher") || "JIS" csv_split(publishers)&.each do |p| xml.contributor do |c| c.role type: "publisher" c.organization do |a| organization(a, p, true, node, !node.attr("publisher")) end end end end |
#org_abbrev ⇒ Object
4 5 6 |
# File 'lib/metanorma/jis/front.rb', line 4 def org_abbrev super.merge("Japanese Industrial Standards" => "JIS") end |
#pdf_converter(node) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/metanorma/jis/converter.rb', line 38 def pdf_converter(node) return if node.attr("no-pdf") return if node.nil? IsoDoc::JIS::PdfConvert.new({}) else IsoDoc::JIS::PdfConvert.new(pdf_extract_attributes(node)) end end |
#presentation_xml_converter(node) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/metanorma/jis/converter.rb', line 49 def presentation_xml_converter(node) if node.nil? IsoDoc::JIS::PresentationXMLConvert.new({}) else IsoDoc::JIS::PresentationXMLConvert.new(doc_extract_attributes(node)) end end |
#script_validate(xmldoc) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/metanorma/jis/converter.rb', line 57 def script_validate(xmldoc) script = xmldoc&.at("//bibdata/script")&.text %w(Jpan Latn).include?(script) or @log.add("Document Attributes", nil, "#{script} is not a recognised script") end |
#validate(doc) ⇒ Object
64 65 66 67 68 |
# File 'lib/metanorma/jis/converter.rb', line 64 def validate(doc) content_validate(doc) schema_validate(formattedstr_strip(doc.dup), File.join(File.dirname(__FILE__), "jis.rng")) end |