metanorma-bipm 2.0.7 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/bipm/base_convert.rb +9 -2
- data/lib/isodoc/bipm/bipm.brochure.xsl +1654 -476
- data/lib/isodoc/bipm/bipm.guide.xsl +1654 -476
- data/lib/isodoc/bipm/bipm.mise-en-pratique.xsl +1654 -476
- data/lib/isodoc/bipm/bipm.rapport.xsl +1654 -476
- data/lib/isodoc/bipm/doccontrol.rb +101 -0
- data/lib/isodoc/bipm/html/html_bipm_titlepage.html +1 -0
- data/lib/isodoc/bipm/init.rb +1 -1
- data/lib/isodoc/bipm/jcgm.standard.xsl +1615 -370
- data/lib/isodoc/bipm/presentation_xml_convert.rb +18 -93
- data/lib/isodoc/bipm/xref.rb +8 -4
- data/lib/metanorma/bipm/biblio.rng +62 -10
- data/lib/metanorma/bipm/converter.rb +38 -108
- data/lib/metanorma/bipm/front.rb +113 -0
- data/lib/metanorma/bipm/isodoc.rng +56 -0
- data/lib/metanorma/bipm/version.rb +1 -1
- data/metanorma-bipm.gemspec +2 -2
- metadata +8 -6
@@ -0,0 +1,101 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module BIPM
|
3
|
+
class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
|
4
|
+
def doccontrol(doc)
|
5
|
+
return unless doc.at(ns("//bibdata/relation[@type = 'supersedes']"))
|
6
|
+
|
7
|
+
clause = <<~DOCCONTROL
|
8
|
+
<doccontrol>
|
9
|
+
<title>Document Control</title>
|
10
|
+
<table unnumbered="true"><tbody>
|
11
|
+
<tr><th>Authors:</th><td/><td>#{list_authors(doc)}</td></tr>
|
12
|
+
#{doccontrol_row1(doc)} #{doccontrol_row2(doc)} #{list_drafts(doc)}
|
13
|
+
</tbody></table></doccontrol>
|
14
|
+
DOCCONTROL
|
15
|
+
doc.root << clause
|
16
|
+
end
|
17
|
+
|
18
|
+
def doccontrol_row1(doc)
|
19
|
+
return "" if list_draft(doc,
|
20
|
+
1) == ["", ""] && list_cochairs(doc).empty?
|
21
|
+
|
22
|
+
<<~ROW
|
23
|
+
<tr>#{list_draft(doc, 1)&.map { |x| "<td>#{x}</td>" }&.join}
|
24
|
+
<td>#{list_cochairs(doc)}</td></tr>
|
25
|
+
ROW
|
26
|
+
end
|
27
|
+
|
28
|
+
def doccontrol_row2(docxml)
|
29
|
+
list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty? and
|
30
|
+
return ""
|
31
|
+
|
32
|
+
<<~ROW
|
33
|
+
<tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
|
34
|
+
<td>#{list_chairs(docxml)}</td></tr>
|
35
|
+
ROW
|
36
|
+
end
|
37
|
+
|
38
|
+
def list_drafts(xml)
|
39
|
+
ret = ""
|
40
|
+
i = 3
|
41
|
+
while list_draft(xml, i) != ["", ""]
|
42
|
+
ret += "<tr>#{list_draft(xml, i).map do |x|
|
43
|
+
"<td>#{x}</td>"
|
44
|
+
end.join} "\
|
45
|
+
"<td/></tr>"
|
46
|
+
i += 1
|
47
|
+
end
|
48
|
+
ret
|
49
|
+
end
|
50
|
+
|
51
|
+
def list_draft(xml, idx)
|
52
|
+
d = xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{idx}]"\
|
53
|
+
"/bibitem")) or return ["", ""]
|
54
|
+
|
55
|
+
draft = d&.at(ns("./version/draft"))&.text and draft = "Draft #{draft}"
|
56
|
+
edn = d&.at(ns("./edition"))&.text and edn = "Version #{edn}"
|
57
|
+
[[draft, edn].join(" "), d&.at(ns("./date"))&.text]
|
58
|
+
end
|
59
|
+
|
60
|
+
def list_authors(xml)
|
61
|
+
ret = list_people(
|
62
|
+
xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
|
63
|
+
)
|
64
|
+
@i18n.boolean_conj(ret, "and")
|
65
|
+
end
|
66
|
+
|
67
|
+
COCHAIR = "xmlns:role[contains(text(),'co-chair')]".freeze
|
68
|
+
CHAIR = "[xmlns:role[contains(text(),'chair')]"\
|
69
|
+
"[not(contains(text(),'co-chair'))]]".freeze
|
70
|
+
|
71
|
+
def list_cochairs(xml)
|
72
|
+
ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
|
73
|
+
ret.empty? and return ""
|
74
|
+
role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
|
75
|
+
label = ret.size > 1 && role ? "#{role}s" : role
|
76
|
+
"#{label}: #{@i18n.boolean_conj(ret, 'and')}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def list_chairs(xml)
|
80
|
+
ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
|
81
|
+
ret.empty? and return ""
|
82
|
+
role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
|
83
|
+
label = ret.size > 1 && role ? "#{role}s" : role
|
84
|
+
"#{label}: #{@i18n.boolean_conj(ret, 'and')}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def list_people(xml, xpath)
|
88
|
+
ret = []
|
89
|
+
xml.xpath(ns(xpath)).each do |p|
|
90
|
+
name = p&.at(ns("./name/completename"))&.text
|
91
|
+
aff = p&.at(ns("./affiliation/organization/abbreviation"))&.text ||
|
92
|
+
p&.at(ns("./affiliation/organization/name"))&.text
|
93
|
+
c = name || ""
|
94
|
+
aff and c += " (#{aff})"
|
95
|
+
ret << c
|
96
|
+
end
|
97
|
+
ret
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|