diff --git a/Gemfile.devel b/Gemfile.devel new file mode 100644 index 0000000..ad72d40 --- /dev/null +++ b/Gemfile.devel @@ -0,0 +1 @@ +gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/publisher-multilingual" diff --git a/lib/isodoc/jis/i18n-en.yaml b/lib/isodoc/jis/i18n-en.yaml index 36969f3..27a4191 100644 --- a/lib/isodoc/jis/i18n-en.yaml +++ b/lib/isodoc/jis/i18n-en.yaml @@ -6,6 +6,9 @@ commentary_page: Comm. JIS: 日本工業規格 permission_footer: Duplication, reprinting, etc. without permission is prohibited by copyright law. chairperson: chairperson +membership_table: Membership Table +full_name: Full Name +affiliation: Affiliation doctype_dict: international-standard: International standard japanese-industrial-standard: International standard diff --git a/lib/isodoc/jis/i18n-ja.yaml b/lib/isodoc/jis/i18n-ja.yaml index 3cfcf16..f755a43 100644 --- a/lib/isodoc/jis/i18n-ja.yaml +++ b/lib/isodoc/jis/i18n-ja.yaml @@ -11,6 +11,9 @@ JIS: 日本工業規格 draft_label: 案 white-paper: 白紙 chairperson: 委員会長 +membership_table: 構成表 +full_name: 氏名 +affiliation: 所属 doctype_dict: international-standard: 日本産業規格 japanese-industrial-standard: 日本産業規格 diff --git a/lib/isodoc/jis/metadata.rb b/lib/isodoc/jis/metadata.rb index 66a09a5..e5bc19f 100644 --- a/lib/isodoc/jis/metadata.rb +++ b/lib/isodoc/jis/metadata.rb @@ -73,20 +73,23 @@ def agency(xml) investigative_committee(xml) end + def extract_role(role, desc) + <<~XPATH + //bibdata/contributor[xmlns:role/@type = '#{role}'][xmlns:role/description = '#{desc}' or xmlns:role/description = '#{desc.downcase}'] + XPATH + end + def investigative_organisation(xml) - xpath = "//bibdata/contributor" \ - "[xmlns:role/@type = 'authorizer'][xmlns:role/description = " \ - "'investigative organization']/organization/name" - org = xml.at(ns(xpath)) + p = extract_role("authorizer", "Investigative organization") + org = xml.at(ns("#{p}/organization/name[@language = '#{@lang}']")) + org ||= xml.at(ns("#{p}/organization/name")) if org then set_encoded(:"investigative-organization", org) else set(:"investigative-organization", get[:publisher]) end end def investigative_committee(xml) - xpath = "//bibdata/contributor" \ - "[xmlns:role/@type = 'authorizer'][xmlns:role/description = " \ - "'investigative committee']" + xpath = extract_role("authorizer", "Investigative committee") if o = xml.at(ns("#{xpath}/organization/name")) set_encoded(:"investigative-committee", o) elsif p = xml.at(ns("#{xpath}/person")) diff --git a/lib/isodoc/jis/presentation_section.rb b/lib/isodoc/jis/presentation_section.rb index 601af4d..f97928f 100644 --- a/lib/isodoc/jis/presentation_section.rb +++ b/lib/isodoc/jis/presentation_section.rb @@ -42,17 +42,22 @@ def commentary_title_hdr(elem) elem.previous = ret end - def toc_title_insert_pt(docxml) - ins = docxml.at(ns("//preface")) || + def make_preface(docxml) + docxml.at(ns("//preface")) || docxml.at(ns("//sections | //annex | //bibliography")) &.before(" ") - &.previous_element or return nil + &.previous_element + end + + def toc_title_insert_pt(docxml) + ins = make_preface(docxml) or return nil ins.children.last.after(" ").next end def preface_rearrange(doc) move_introduction(doc) super + move_participants(doc) end def move_introduction(doc) @@ -63,6 +68,45 @@ def move_introduction(doc) dest.children.first.next = source end + def move_participants(doc) + p = doc.at(ns("//clause[@type = 'participants']")) or return + t = participant_table(p) or return + p.remove + ins = make_preface(doc) or return nil + ins.children.first.previous = t + end + + def participant_table(clause) + s = clause.at(ns("./sourcecode")) or return nil + y = YAML.safe_load(s.children.to_xml(encoding: "UTF-8")) or return nil + y.is_a?(Array) or return nil + out1 = <<~OUTPUT + #{@meta.get[:"investigative-committee"]} #{@i18n.membership_table} + + + + + + OUTPUT + out2 = <<~OUTPUT +
#{@i18n.full_name}#{@i18n.affiliation}
+ OUTPUT + "#{out1}#{participant_rows(y)}#{out2}" + end + + def participant_rows(yaml) + yaml.map do |y| + r = y["role"] ? @i18n.l10n("(#{y['role']})") : "" + n = y["name"] + if n.is_a?(Hash) + n = + if @lang == "ja" then "#{n['surname']} #{n['givenname']}" + else "#{n['givenname']} #{n['surname']}" end + end + "#{r}#{n}#{y['affiliation']}" + end.join("\n") + end + def middle_title(docxml) s = docxml.at(ns("//sections")) or return elem = s.children.first diff --git a/lib/metanorma/jis/front.rb b/lib/metanorma/jis/front.rb index 8005a05..8a91992 100644 --- a/lib/metanorma/jis/front.rb +++ b/lib/metanorma/jis/front.rb @@ -92,9 +92,9 @@ def extract_org_attrs_address(node, opts, suffix) def multiling_noko_value(value, tag, xml) if value.is_a?(Hash) - xml.send tag do |t| - value.each do |k, v| - t.variant v, language: k + value.each do |k, v| + xml.send tag, language: k do |x| + x << v end end elsif value.is_a?(Array) diff --git a/spec/isodoc/metadata_spec.rb b/spec/isodoc/metadata_spec.rb index cd0a2f3..10d8aed 100644 --- a/spec/isodoc/metadata_spec.rb +++ b/spec/isodoc/metadata_spec.rb @@ -39,15 +39,13 @@ Investigative organization - - 日本産業標準調査会 - Japanese Industrial Standards Committee - + 日本産業標準調査会 + Japanese Industrial Standards Committee - investigative committee + Investigative committee @@ -62,7 +60,7 @@ - investigative committee + Investigative committee @@ -155,7 +153,7 @@ :"investigative-committee"=>"Committee 123", :"investigative-committee-representative-name"=>"KUROSAWA Akira", :"investigative-committee-representative-role"=>"chairperson", - :"investigative-organization"=>"Japanese Industrial Standards", + :"investigative-organization"=>"Japanese Industrial Standards Committee", :lang=>"en", :publisher=>"Japanese Industrial Standards", :revdate=>"2000-01-01", diff --git a/spec/isodoc/section_spec.rb b/spec/isodoc/section_spec.rb index 6ca5425..1883012 100644 --- a/spec/isodoc/section_spec.rb +++ b/spec/isodoc/section_spec.rb @@ -405,157 +405,158 @@ OUTPUT word = <<~OUTPUT - -
-

 

-
-

-
-

-
-

-
-

-
-

Contents

-
-

 

-
-

-
-

-
-

- 日本工業規格 -   -   -   -   -   -   -   - JIS -

-

-   - Z 1000-1.3: - 2000 -

-

-

Introduction — Main Title — Title —

-

- Part : -
- Title Part -

-

Introduction Française — Titre Principal —

-

- その : -
- Part du Titre -

-
-

- 1 -   - Normative References -

-
-

- 1.1 -   - Normative References 1 -

-
-
-

-
-

-
-

- Annex A -
- (normative) -
- First Annex -

-
-

-
-

-
-

- Annex B -
- (informative) -
- Second Annex -

-
-

-
-

-
-

Bibliography

-
- -

-
-

-
-
-

- JIS Z 1000-1.3 : - 2000 -

-

Introduction — Main Title — Title —

-

- Part : -
- Title Part -

-

Commentary

-
-

- 1 -   - First clause -

-
-

- 1.1 -   - First subclause -

-
-
-
-
- -

-
-

-
-
-

- JIS Z 1000-1.3 : - 2000 -

-

Introduction — Main Title — Title —

-

- Part : -
- Title Part -

-

Another Commentary

-
-
-
-
-
- + +
+

 

+
+

+
+

+
+

+
+

+
+

Contents

+
+

 

+
+

+
+

+
+

+ 日本工業規格 +   +   +   +   +   +   +   + JIS +

+

+   + Z 1000-1.3: + 2000 +

+

+

Introduction — Main Title — Title —

+

+ Part : +
+ Title Part +

+

Introduction Française — Titre Principal —

+

+ その : +
+ Part du Titre +

+
+

+ 1 +   + Normative References +

+
+

+ 1.1 +   + Normative References 1 +

+
+
+

+
+

+
+

+ Annex A +
+ (normative) +
+ First Annex +

+
+

+
+

+
+

+ Annex B +
+ (informative) +
+ Second Annex +

+
+

+
+

+
+

Bibliography

+
+ +

+
+

+
+
+

+ JIS Z 1000-1.3 : + 2000 +

+

Introduction — Main Title — Title —

+

+ Part : +
+ Title Part +

+

Commentary

+
+

+ 1 +   + First clause +

+
+

+ 1.1 +   + First subclause +

+
+
+
+
+ +

+
+

+
+
+

+ JIS Z 1000-1.3 : + 2000 +

+

Introduction — Main Title — Title —

+

+ Part : +
+ Title Part +

+

Another Commentary

+
+
+
+
+
+ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::JIS::PresentationXMLConvert.new(presxml_options) + expect(Xml::C14n.format(strip_guid(IsoDoc::JIS::PresentationXMLConvert + .new(presxml_options) .convert("test", input, true)) .sub(%r{.*}m, ""))) .to be_equivalent_to Xml::C14n.format(presxml) @@ -567,4 +568,131 @@ .sub(/^.*.*$}m, "")) .to be_equivalent_to Xml::C14n.format(word) end + + it "processes contributor table" do + input = <<~INPUT + + + en + + 国土交通省都市局 + Investigative organization + language="ja">日本産業標準調査会Japanese Industrial Standards Committee + Investigative committee + 日本産業標準調査会 標準第一部会 + + + + + + - name: + surname: 酒井 + givenname: 信介 + affiliation: 横浜国立大学 + role: 部会長 + - name: + surname: 伊藤 + givenname: 弘 + affiliation: 国立研究開発法人建築研究所 + role: 委員 + - name: + surname: 宇治 + givenname: 公隆 + affiliation: 国立研究開発法人建築研究所 + + + + + Clause + + + + INPUT + presxml = <<~OUTPUT + + + 日本産業標準調査会 標準第一部会 Membership Table + + + + + + + + + + + + + + + + + + + + + + + +
+ Full NameAffiliation
(部会長)信介 酒井横浜国立大学
(委員)弘 伊藤国立研究開発法人建築研究所
+ 公隆 宇治国立研究開発法人建築研究所
+
+ + Contents + +
+ OUTPUT + output = Nokogiri::XML(IsoDoc::JIS::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true)) + output = output.at("//xmlns:preface") + expect(Xml::C14n.format(strip_guid(output.to_xml))) + .to be_equivalent_to Xml::C14n.format(strip_guid(presxml)) + + presxml = <<~OUTPUT + + + 日本産業標準調査会 標準第一部会 構成表 + + + + + + + + + + + + + + + + + + + + + + + +
+ 氏名所属
(部会長)酒井 信介横浜国立大学
(委員)伊藤 弘国立研究開発法人建築研究所
+ 宇治 公隆国立研究開発法人建築研究所
+
+ + 目 次 + +
+ OUTPUT + output = Nokogiri::XML(IsoDoc::JIS::PresentationXMLConvert + .new(presxml_options) + .convert("test", input.sub("en", + "ja"), true)) + output = output.at("//xmlns:preface") + expect(Xml::C14n.format(strip_guid(output.to_xml))) + .to be_equivalent_to Xml::C14n.format(strip_guid(presxml)) + end end diff --git a/spec/metanorma/base_spec.rb b/spec/metanorma/base_spec.rb index f13c4b8..20983f0 100644 --- a/spec/metanorma/base_spec.rb +++ b/spec/metanorma/base_spec.rb @@ -120,20 +120,16 @@ - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -142,10 +138,8 @@ Investigative organization - - 日本産業標準調査会 - Japanese Industrial Standards Committee - + 日本産業標準調査会 + Japanese Industrial Standards Committee @@ -172,10 +166,8 @@ 2000 - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -214,7 +206,7 @@

官 報 掲 載 日:平成十二年2月1日

原 案 作 成 者:一般財団法人日本規格協会

(〒108-0073 東京都港区三田 3-13-12 三田 MT ビル TEL 03-4231-8530)

-

審 議 部 会:日本工業規格

+

審 議 部 会:日本産業標準調査会日本産業標準調査会 標準第一部会

この規格についての意見又は質問は,上記原案作成者又は経済産業省産業技術環境局 国際標準課(〒100-8901 東京 都千代田区霞が関 1-3-1)にご連絡ください。

@@ -253,20 +245,16 @@ - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -275,10 +263,8 @@ Investigative organization - - 日本産業標準調査会 - Japanese Industrial Standards Committee - + 日本産業標準調査会 + Japanese Industrial Standards Committee
@@ -305,10 +291,8 @@ 2000 - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -347,7 +331,7 @@ Date of publication in the Official Gazette: 2000-02-01 Draft creator: Japanese Standards Association (Mita MT Building, 3-13-12 Mita, Minato-ku, Tokyo 108-0073 Tel: 03-4231-8530) - Investigative Working Group: Japanese Industrial Standards

+ Investigative Working Group: Japanese Industrial Standards Committee 日本産業標準調査会 標準第一部会

Any comments or questions regarding this standard should be directed to the above drafter or the International Standardization Division, Industrial Science and Technology Policy and Environment Bureau, Ministry of Economy, Trade and Industry (Tokyo 100-8901 Tokyo, Japan). Please contact 1-3-1 Kasumigaseki, Chiyoda-ku, Tokyo. In accordance with the provisions of the Industrial Standardization Law, Japanese Industrial Standards shall be reviewed by the Japan Industrial Standards Committee by the date when at least five years have passed. It will be put up for discussion and promptly confirmed, amended or repealed.

@@ -384,20 +368,16 @@ - - JAPANESE NAME PUBLISHER - English name publisher - + JAPANESE NAME PUBLISHER + English name publisher Publisher Abbrev - - JAPANESE NAME PUBLISHER - English name publisher - + JAPANESE NAME PUBLISHER + English name publisher Publisher Abbrev @@ -414,10 +394,8 @@ #{Date.today.year} - - JAPANESE NAME PUBLISHER - English name publisher - + JAPANESE NAME PUBLISHER + English name publisher Publisher Abbrev @@ -486,20 +464,16 @@ - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -545,10 +519,8 @@ #{Date.today.year} - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -626,20 +598,16 @@ - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -653,10 +621,8 @@ #{Date.today.year} - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -859,20 +825,16 @@ - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -886,10 +848,8 @@ 2022 - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1586d00..e02513d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -181,20 +181,16 @@ def boilerplate_read(file) - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS @@ -208,10 +204,8 @@ def boilerplate_read(file) #{Time.new.year} - - 日本工業規格 - Japanese Industrial Standards - + 日本工業規格 + Japanese Industrial Standards JIS