asciidoctor-gb 0.1.5 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.tb.yml +20 -10
- data/LICENSE +25 -0
- data/README.adoc +262 -34
- data/asciidoctor-gb.gemspec +2 -1
- data/bin/rspec +18 -0
- data/lib/asciidoctor/gb/biblio.rng +602 -0
- data/lib/asciidoctor/gb/converter.rb +104 -70
- data/lib/asciidoctor/gb/front.rb +109 -61
- data/lib/asciidoctor/gb/gbstandard.rng +135 -31
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.gif +0 -0
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.png +0 -0
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.svg +980 -0
- data/lib/asciidoctor/gb/html/{gb.css → gb.scss} +133 -219
- data/lib/asciidoctor/gb/html/html_gb_intro.html +1 -37
- data/lib/asciidoctor/gb/html/html_gb_titlepage.html +6 -5
- data/lib/asciidoctor/gb/html/{htmlstyle.css → htmlstyle.scss} +85 -3
- data/lib/asciidoctor/gb/html/word_gb_intro.html +1 -1
- data/lib/asciidoctor/gb/html/word_gb_titlepage.html +320 -166
- data/lib/asciidoctor/gb/html/{wordstyle.css → wordstyle.scss} +605 -429
- data/lib/asciidoctor/gb/isodoc.rng +36 -564
- data/lib/asciidoctor/gb/isostandard.rng +198 -91
- data/lib/asciidoctor/gb/section_input.rb +21 -56
- data/lib/asciidoctor/gb/validate.rb +115 -0
- data/lib/asciidoctor/gb/version.rb +1 -1
- data/lib/asciidoctor-gb.rb +2 -1
- data/lib/isodoc/gb/agencies.rb +327 -0
- data/lib/isodoc/gb/block_output.rb +86 -0
- data/lib/isodoc/gb/gbcleanup.rb +87 -0
- data/lib/isodoc/gb/gbconvert.rb +153 -0
- data/lib/isodoc/gb/gbwordconvert.rb +89 -0
- data/lib/isodoc/gb/html/blank.png +0 -0
- data/lib/isodoc/gb/html/footer.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.svg +980 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.svg +13 -0
- data/lib/isodoc/gb/html/gb.scss +556 -0
- data/lib/isodoc/gb/html/header.html +216 -0
- data/lib/isodoc/gb/html/html_gb_intro.html +9 -0
- data/lib/isodoc/gb/html/html_gb_titlepage.html +99 -0
- data/lib/isodoc/gb/html/htmlstyle.scss +269 -0
- data/lib/isodoc/gb/html/logo.png +0 -0
- data/lib/isodoc/gb/html/scripts.html +71 -0
- data/lib/isodoc/gb/html/word_gb_intro.html +3 -0
- data/lib/isodoc/gb/html/word_gb_titlepage.html +388 -0
- data/lib/isodoc/gb/html/wordstyle.scss +2543 -0
- data/lib/isodoc/gb/i18n-en.yaml +12 -0
- data/lib/isodoc/gb/i18n-zh-Hans.yaml +12 -0
- data/lib/isodoc/gb/i18n.rb +20 -0
- data/lib/isodoc/gb/metadata.rb +216 -0
- data/lib/{asciidoctor → isodoc}/gb/section_output.rb +22 -4
- data/lib/isodoc/gb/xref_gen.rb +17 -0
- metadata +75 -15
- data/lib/asciidoctor/gb/agencies.rb +0 -186
- data/lib/asciidoctor/gb/gbconvert.rb +0 -86
- data/lib/asciidoctor/gb/metadata.rb +0 -186
- data/lib/asciidoctor/gb/xref_gen.rb +0 -25
@@ -0,0 +1,115 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Gb
|
3
|
+
class Converter < ISO::Converter
|
4
|
+
|
5
|
+
def validate(doc)
|
6
|
+
content_validate(doc)
|
7
|
+
schema_validate(formattedstr_strip(doc.dup),
|
8
|
+
File.join(File.dirname(__FILE__), "gbstandard.rng"))
|
9
|
+
end
|
10
|
+
|
11
|
+
def content_validate(doc)
|
12
|
+
super
|
13
|
+
bilingual_terms_validate(doc.root)
|
14
|
+
issuer_validate(doc.root)
|
15
|
+
prefix_validate(doc.root)
|
16
|
+
doc_converter(nil).gbtype_validate(doc.root)
|
17
|
+
end
|
18
|
+
|
19
|
+
def prefix_validate(root)
|
20
|
+
prefix = root&.at("//gbprefix")&.text
|
21
|
+
scope = root&.at("//gbscope")&.text
|
22
|
+
case scope
|
23
|
+
when "social"
|
24
|
+
/^[A-Za-z]{3,6}$/.match? prefix or
|
25
|
+
warn("#{prefix} is improperly formatted for social standards")
|
26
|
+
when "enterprise"
|
27
|
+
/^[A-Z0-9]{3,}$/.match? prefix or
|
28
|
+
warn("#{prefix} is improperly formatted for enterprise standards")
|
29
|
+
when "sector"
|
30
|
+
%w(AQ BB CB CH CJ CY DA DB DL DZ EJ FZ GA GH GM GY HB HG HJ HS HY
|
31
|
+
JB JC JG JR JT JY LB LD LS LY MH MT MZ NY QB QC QJ QX SB SC SH
|
32
|
+
SJ SL SN SY TB TD TJ TY WB WH WJ WM WS WW XB YB YC YD YS YY YZ
|
33
|
+
ZY).include? prefix or
|
34
|
+
warn("#{prefix} is not a legal sector standard prefix")
|
35
|
+
when "local"
|
36
|
+
%w(11 12 13 14 15 21 22 23 31 32 33 34 35 36 37 41 42 43 44 45 46
|
37
|
+
50 51 52 53 54 61 62 63 64 65 71 81 82 end).include? prefix or
|
38
|
+
warn("#{prefix} is not a legal local standard prefix")
|
39
|
+
when "national"
|
40
|
+
%w(GB GBZ GJB GBn GHZB GWPB JJF JJG).include? prefix or
|
41
|
+
warn("#{prefix} is not a legal national standard prefix")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def issuer_validate(root)
|
46
|
+
issuer = root&.at("//bibdata/contributor[role/@type = 'issuer']/"\
|
47
|
+
"organization/name")&.text
|
48
|
+
scope = root&.at("//gbscope")&.text
|
49
|
+
if %w(enterprise social).include?(scope) && issuer == "GB"
|
50
|
+
warn "No issuer provided for #{scope} standard"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def check_bilingual(t, element)
|
55
|
+
zh = t.at(".//#{element}[@language = 'zh']")
|
56
|
+
en = t.at(".//#{element}[@language = 'en']")
|
57
|
+
(en.nil? || en.text.empty?) && !(zh.nil? || zh.text.empty?) &&
|
58
|
+
warn("GB: #{element} term #{zh.text} has no English counterpart")
|
59
|
+
!(en.nil? || en.text.empty?) && (zh.nil? || zh.text.empty?) &&
|
60
|
+
warn("GB: #{element} term #{en.text} has no Chinese counterpart")
|
61
|
+
end
|
62
|
+
|
63
|
+
def bilingual_terms_validate(root)
|
64
|
+
root.xpath("//term").each do |t|
|
65
|
+
check_bilingual(t, "preferred")
|
66
|
+
check_bilingual(t, "admitted")
|
67
|
+
check_bilingual(t, "deprecates")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def title_intro_validate(root)
|
72
|
+
title_intro_en = root.at("//title-intro[@language='en']")
|
73
|
+
title_intro_zh = root.at("//title-intro[@language='zh']")
|
74
|
+
if title_intro_en.nil? && !title_intro_zh.nil?
|
75
|
+
warn "No English Title Intro!"
|
76
|
+
end
|
77
|
+
if !title_intro_en.nil? && title_intro_zh.nil?
|
78
|
+
warn "No Chinese Title Intro!"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def title_main_validate(root)
|
83
|
+
title_main_en = root.at("//title-main[@language='en']")
|
84
|
+
title_main_zh = root.at("//title-main[@language='zh']")
|
85
|
+
if title_main_en.nil? && !title_main_zh.nil?
|
86
|
+
warn "No English Title!"
|
87
|
+
end
|
88
|
+
if !title_main_en.nil? && title_main_zh.nil?
|
89
|
+
warn "No Chinese Title!"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def title_part_validate(root)
|
94
|
+
title_part_en = root.at("//title-part[@language='en']")
|
95
|
+
title_part_zh = root.at("//title-part[@language='zh']")
|
96
|
+
if title_part_en.nil? && !title_part_zh.nil?
|
97
|
+
warn "No English Title Part!"
|
98
|
+
end
|
99
|
+
if !title_part_en.nil? && title_part_zh.nil?
|
100
|
+
warn "No Chinese Title Part!"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def norm_bibitem_style(root)
|
105
|
+
root.xpath(NORM_BIBITEMS).each do |b|
|
106
|
+
if b.at(Asciidoctor::ISO::Cleanup::ISO_PUBLISHER_XPATH).nil?
|
107
|
+
unless /^#{GBCODE}(?![A-Z])/.match? b.at("./docidentifier").text
|
108
|
+
Asciidoctor::ISO::Utils::warning(b, NORM_ISO_WARN, b.text)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/asciidoctor-gb.rb
CHANGED
@@ -0,0 +1,327 @@
|
|
1
|
+
require "isodoc"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
module Gb
|
5
|
+
class Convert < IsoDoc::Convert
|
6
|
+
SECTOR = { "zh" => {
|
7
|
+
AQ: { industry: "安全生产", admin: "国家安全生产管理局" },
|
8
|
+
BB: { industry: "包装", admin: "国家发改委" },
|
9
|
+
CB: { industry: "船舶", admin: "国防科学工业委员会" },
|
10
|
+
CH: { industry: "测绘", admin: "国家测绘局" },
|
11
|
+
CJ: { industry: "城镇建设", admin: "建设部" },
|
12
|
+
CY: { industry: "新闻出版", admin: "国家新闻出版总署" },
|
13
|
+
DA: { industry: "档案", admin: "国家档案局" },
|
14
|
+
DB: { industry: "地震", admin: "中国地震局" },
|
15
|
+
DL: { industry: "电力", admin: "国家发改委" },
|
16
|
+
DZ: { industry: "地质矿产", admin: "国土资源部" },
|
17
|
+
EJ: { industry: "核工业", admin: "国防科学工业委员会" },
|
18
|
+
FZ: { industry: "纺织", admin: "国家发改委" },
|
19
|
+
GA: { industry: "公共安全", admin: "公安部" },
|
20
|
+
GH: { industry: "供销", admin: "中华全国供销合作总社" },
|
21
|
+
GM: { industry: "密码", admin: "国家密码管理局" },
|
22
|
+
GY: { industry: "广播电影电视", admin: "国家广播电影电视总局" },
|
23
|
+
HB: { industry: "航空", admin: "国防科学工业委员会" },
|
24
|
+
HG: { industry: "化工", admin: "国家发改委" },
|
25
|
+
HJ: { industry: "环境保护", admin: "国家环境保护总局" },
|
26
|
+
HS: { industry: "海关", admin: "海关总署" },
|
27
|
+
HY: { industry: "海洋", admin: "国家海洋局" },
|
28
|
+
JB: { industry: "机械", admin: "国家发改委" },
|
29
|
+
JC: { industry: "建材", admin: "国家发改委" },
|
30
|
+
JG: { industry: "建筑工业", admin: "建设部" },
|
31
|
+
JR: { industry: "金融", admin: "中国人民银行" },
|
32
|
+
JT: { industry: "交通", admin: "交通部" },
|
33
|
+
JY: { industry: "教育", admin: "教育部" },
|
34
|
+
LB: { industry: "旅游", admin: "国家旅游局" },
|
35
|
+
LD: { industry: "劳动和劳动安全", admin: "劳动和社会保障部" },
|
36
|
+
LS: { industry: "粮食", admin: "国家粮食局" },
|
37
|
+
LY: { industry: "林业", admin: "国家林业局" },
|
38
|
+
MH: { industry: "民用航空", admin: "中国民航管理总局" },
|
39
|
+
MT: { industry: "煤炭", admin: "国家发改委" },
|
40
|
+
MZ: { industry: "民政", admin: "民政部" },
|
41
|
+
NY: { industry: "农业", admin: "农业部" },
|
42
|
+
QB: { industry: "轻工", admin: "国家发改委" },
|
43
|
+
QC: { industry: "汽车", admin: "国家发改委" },
|
44
|
+
QJ: { industry: "航天", admin: "国防科学工业委员会" },
|
45
|
+
QX: { industry: "气象", admin: "中国气象局" },
|
46
|
+
SB: { industry: "国内贸易", admin: "商务部" },
|
47
|
+
SC: { industry: "水产", admin: "农业部" },
|
48
|
+
SH: { industry: "石油化工", admin: "国家发改委" },
|
49
|
+
SJ: { industry: "电子", admin: "信息产业部" },
|
50
|
+
SL: { industry: "水利", admin: "水利部" },
|
51
|
+
SN: { industry: "商检", admin: "国家质量监督检验检疫总局" },
|
52
|
+
SY: { industry: "石油天然气", admin: "国家发改委" },
|
53
|
+
TB: { industry: "铁道", admin: "铁道部" },
|
54
|
+
TD: { industry: "土地管理", admin: "国土资源部" },
|
55
|
+
TJ: { industry: "铁道交通", admin: "铁道部标准所" },
|
56
|
+
TY: { industry: "体育", admin: "国家体育总局" },
|
57
|
+
WB: { industry: "物资管理", admin: "国家发改委" },
|
58
|
+
WH: { industry: "文化", admin: "文化部" },
|
59
|
+
WJ: { industry: "兵工民品", admin: "国防科学工业委员会" },
|
60
|
+
WM: { industry: "外经贸", admin: "外经贸部科技司" },
|
61
|
+
WS: { industry: "卫生", admin: "卫生部" },
|
62
|
+
WW: { industry: "文物保护", admin: "国家文物局" },
|
63
|
+
XB: { industry: "稀土", admin: "国家发改委稀土办公室" },
|
64
|
+
YB: { industry: "黑色冶金", admin: "国家发改委" },
|
65
|
+
YC: { industry: "烟草", admin: "国家烟草专卖局" },
|
66
|
+
YD: { industry: "通信", admin: "信息产业部" },
|
67
|
+
YS: { industry: "有色冶金", admin: "国家发改委" },
|
68
|
+
YY: { industry: "医药", admin: "国家食品药品监督管理局" },
|
69
|
+
YZ: { industry: "邮政", admin: "国家邮政局" },
|
70
|
+
ZY: { industry: "中医药", admin: "国家中医药管理局" },
|
71
|
+
},
|
72
|
+
"en" => {
|
73
|
+
AQ: { industry: "Production Safety", admin: "State Administration of Work Safety" },
|
74
|
+
BB: { industry: "Packaging", admin: "China National Packaging Industry Corporation" },
|
75
|
+
CB: { industry: "Ships", admin: "National Defense Commission" },
|
76
|
+
CH: { industry: "Surveying and Mapping", admin: "National Bureau of Surveying and Mapping" },
|
77
|
+
CJ: { industry: "Town Construction", admin: "Ministry of Construction" },
|
78
|
+
CY: { industry: "News Publishing", admin: "State Press and Publication Administration" },
|
79
|
+
DA: { industry: "Archiving", admin: "National Archival Bureau" },
|
80
|
+
DB: { industry: "Seismology", admin: "National Seismological Bureau" },
|
81
|
+
DL: { industry: "Electricity", admin: "State Economic and Trade Commission" },
|
82
|
+
DZ: { industry: "Geological and Mineral Products", admin: "Ministry of Land and Resources" },
|
83
|
+
EJ: { industry: "Nuclear Industry", admin: "National Defense Commission" },
|
84
|
+
FZ: { industry: "Textile", admin: "State Economic and Trade Commission" },
|
85
|
+
GA: { industry: "Public Safety", admin: "Ministry of Public Security" },
|
86
|
+
GH: { industry: "Supply and Marketing", admin: "China Federation of Supply and Marketing Cooperatives" },
|
87
|
+
GM: { industry: "Cryptography", admin: "State Administration Of Cryptography" },
|
88
|
+
GY: { industry: "Radio, Film and Television", admin: "State Administration of Radio, Film and Television" },
|
89
|
+
HB: { industry: "Aviation", admin: "National Defense Commission" },
|
90
|
+
HG: { industry: "Chemical Industry", admin: "State Economic and Trade Commission" },
|
91
|
+
HJ: { industry: "Environmental Protection", admin: "State Environmental Protection Administration" },
|
92
|
+
HS: { industry: "Customs", admin: "General Administration of Customs" },
|
93
|
+
HY: { industry: "Oceanography", admin: "State Oceanic Administration" },
|
94
|
+
JB: { industry: "Mechanical Engineering", admin: "State Economic and Trade Commission" },
|
95
|
+
JC: { industry: "Building Materials", admin: "State Economic and Trade Commission" },
|
96
|
+
JG: { industry: "Construction Industry", admin: "Ministry of Construction" },
|
97
|
+
JR: { industry: "Financial", admin: "People’s Bank of China" },
|
98
|
+
JT: { industry: "Traffic", admin: "Ministry of Communications" },
|
99
|
+
JY: { industry: "Education", admin: "Ministry of Education" },
|
100
|
+
LB: { industry: "Tourism", admin: "National Tourism Bureau" },
|
101
|
+
LD: { industry: "Labor and Work Safety", admin: "Ministry of Labor and Social Security" },
|
102
|
+
LS: { industry: "Food", admin: "National Food Administration" },
|
103
|
+
LY: { industry: "Forestry", admin: "State Forestry Administration" },
|
104
|
+
MH: { industry: "Civil Aviation", admin: "Civil Aviation Administration" },
|
105
|
+
MT: { industry: "Coal", admin: "State Economic and Trade Commission" },
|
106
|
+
MZ: { industry: "Civil Affairs", admin: "Ministry of Civil Affairs" },
|
107
|
+
NY: { industry: "Agriculture", admin: "Ministry of Agriculture" },
|
108
|
+
QB: { industry: "Light Industry", admin: "State Economic and Trade Commission" },
|
109
|
+
QC: { industry: "Automotive", admin: "State Economic and Trade Commission" },
|
110
|
+
QJ: { industry: "Aerospace", admin: "National Defense Commission" },
|
111
|
+
QX: { industry: "Meteorological", admin: "China Meteorological Administration" },
|
112
|
+
SB: { industry: "Domestic Business", admin: "Ministry of Commerce" },
|
113
|
+
SC: { industry: "Aquatic Products", admin: "Ministry of Agriculture" },
|
114
|
+
SH: { industry: "Petrochemical", admin: "State Economic and Trade Commission" },
|
115
|
+
SJ: { industry: "Electronics", admin: "Ministry of Information Industry" },
|
116
|
+
SL: { industry: "Water Resources", admin: "Ministry of Water Resources" },
|
117
|
+
SN: { industry: "Inspection", admin: "General Administration of Quality Supervision, Inspection and Quarantine" },
|
118
|
+
SY: { industry: "Natural Gas", admin: "State Economic and Trade Commission" },
|
119
|
+
TB: { industry: "Rail Transport", admin: "Ministry of Railways" },
|
120
|
+
TD: { industry: "Land Management", admin: "Ministry of Land and Resources" },
|
121
|
+
TJ: { industry: "Railway Traffic", admin: "Ministry of Railways Standards" },
|
122
|
+
TY: { industry: "Sports", admin: "National Department of Sport" },
|
123
|
+
WB: { industry: "Materials Management", admin: "State Economic and Trade Commission" },
|
124
|
+
WH: { industry: "Culture", admin: "Ministry of Culture" },
|
125
|
+
WJ: { industry: "Ordnance", admin: "National Defense Commission" },
|
126
|
+
WM: { industry: "Foreign Trade", admin: "Ministry of Foreign Trade and Economic Cooperation" },
|
127
|
+
WS: { industry: "Health", admin: "Ministry of Health" },
|
128
|
+
WW: { industry: "Cultural Relics Protection", admin: "National Heritage Board" },
|
129
|
+
XB: { industry: "Rare Earths", admin: "State Planning Commission Rare Earths Office" },
|
130
|
+
YB: { industry: "Ferrous Metallurgy", admin: "State Economic and Trade Commission" },
|
131
|
+
YC: { industry: "Tobacco", admin: "State Tobacco Monopoly Bureau" },
|
132
|
+
YD: { industry: "Communication", admin: "Ministry of Information Industry" },
|
133
|
+
YS: { industry: "Non-Ferrous Metallurgy", admin: "State Economic and Trade Commission" },
|
134
|
+
YY: { industry: "Medicine", admin: "State Food and Drug Administration" },
|
135
|
+
YZ: { industry: "Postal", admin: "State Post Office" },
|
136
|
+
ZY: { industry: "Chinese Medicine", admin: "State Administration of Traditional Chinese Medicine" },
|
137
|
+
}
|
138
|
+
}.freeze
|
139
|
+
|
140
|
+
NATIONAL = {
|
141
|
+
"zh" => {
|
142
|
+
GB: { name: "中华人民共和国国家标准",
|
143
|
+
admin: ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] },
|
144
|
+
"GB/T": { name: "中华人民共和国国家标准",
|
145
|
+
admin: ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] },
|
146
|
+
"GB/Z": { name: "中华人民共和国国家标准化指导性技术文件",
|
147
|
+
admin: ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] },
|
148
|
+
GBZ: { name: "中华人民共和国国家职业卫生标准", admin: "中华人民共和国卫生部" },
|
149
|
+
GJB: { name: "中华人民共和国国家军用标准", admin: "中国人民解放军装备总部" },
|
150
|
+
GBn: { name: "中华人民共和国国家内部标准", admin: "" },
|
151
|
+
GHZB: { name: "中华人民共和国国家环境质量标准", admin: "" }, GWKB: { name: "中华人民共和国国家环境保护标准", admin: "环境保护部" },
|
152
|
+
GWPB: { name: "中华人民共和国国家污染物排放标准", admin: "" },
|
153
|
+
JJF: { name: "中华人民共和国国家计量技术规范", admin: "中华人民共和国国家质量监督检验检疫总局" },
|
154
|
+
JJG: { name: "中华人民共和国国家计量检定规程", admin: "中华人民共和国国家质量监督检验检疫总局" },
|
155
|
+
},
|
156
|
+
"en" => {
|
157
|
+
GB: { name: "National standard",
|
158
|
+
admin: "General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China" },
|
159
|
+
"GB/T": { name: "National standard (Recommended)",
|
160
|
+
admin: "General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China" },
|
161
|
+
"GB/Z": { name: "Standardized guidelines",
|
162
|
+
admin: "General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China" },
|
163
|
+
GBZ: { name: "National occupational health standards", admin: "Ministry of Health" },
|
164
|
+
GJB: { name: "National military standards", admin: "Chinese People’s Liberation Army Equipment Headquarters" },
|
165
|
+
GBn: { name: "National internal standards", admin: "" },
|
166
|
+
GHZB: { name: "National environmental quality standards", admin: "" }, GWKB: { name: "National Environmental Protection Standards", admin: "Ministry of Environmental Protection" },
|
167
|
+
GWPB: { name: "National pollutant discharge standards", admin: "" },
|
168
|
+
JJF: { name: "National calibration specifications", admin: "General Administration of Quality Supervision, Inspection and Quarantine" },
|
169
|
+
JJG: { name: "National calibration verification regulations", admin: "General Administration of Quality Supervision, Inspection and Quarantine" },
|
170
|
+
}
|
171
|
+
}.freeze
|
172
|
+
|
173
|
+
LOCAL = {
|
174
|
+
"zh" => {
|
175
|
+
"11": "北京市",
|
176
|
+
"12": "天津市",
|
177
|
+
"13": "河北省",
|
178
|
+
"14": "山西省",
|
179
|
+
"15": "内蒙古自治区",
|
180
|
+
"21": "辽宁省",
|
181
|
+
"22": "吉林省",
|
182
|
+
"23": "黑龙江省",
|
183
|
+
"31": "上海市",
|
184
|
+
"32": "江苏省",
|
185
|
+
"33": "浙江省",
|
186
|
+
"34": "安徽省",
|
187
|
+
"35": "福建省",
|
188
|
+
"36": "江西省",
|
189
|
+
"37": "山东省",
|
190
|
+
"41": "河南省",
|
191
|
+
"42": "湖北省",
|
192
|
+
"43": "湖南省",
|
193
|
+
"44": "广东省",
|
194
|
+
"45": "广西壮族自治区",
|
195
|
+
"46": "海南省",
|
196
|
+
"50": "重庆市",
|
197
|
+
"51": "四川省",
|
198
|
+
"52": "贵州省",
|
199
|
+
"53": "云南省",
|
200
|
+
"54": "西藏自治区",
|
201
|
+
"61": "陕西省",
|
202
|
+
"62": "甘肃省",
|
203
|
+
"63": "青海省",
|
204
|
+
"64": "宁夏回族自治区",
|
205
|
+
"65": "新疆维吾尔自治区",
|
206
|
+
"71": "台湾省",
|
207
|
+
"81": "香港特别行政区",
|
208
|
+
"82": "澳门特别行政区",
|
209
|
+
},
|
210
|
+
"en" => {
|
211
|
+
"11": "Beijing City",
|
212
|
+
"12": "Tianjin",
|
213
|
+
"13": "Hebei Province",
|
214
|
+
"14": "Shanxi Province",
|
215
|
+
"15": "Inner Mongolia Autonomous Region",
|
216
|
+
"21": "Liaoning Province",
|
217
|
+
"22": "Jilin Province",
|
218
|
+
"23": "Heilongjiang Province",
|
219
|
+
"31": "Shanghai",
|
220
|
+
"32": "Jiangsu Province",
|
221
|
+
"33": "Zhejiang Province",
|
222
|
+
"34": "Anhui Province",
|
223
|
+
"35": "Fujian Province",
|
224
|
+
"36": "Jiangxi Province",
|
225
|
+
"37": "Shandong Province",
|
226
|
+
"41": "Henan Province",
|
227
|
+
"42": "Hubei Province",
|
228
|
+
"43": "Hunan Province",
|
229
|
+
"44": "Guangdong Province",
|
230
|
+
"45": "Guangxi Zhuang Autonomous Region",
|
231
|
+
"46": "Hainan",
|
232
|
+
"50": "Chongqing",
|
233
|
+
"51": "Sichuan Province",
|
234
|
+
"52": "Guizhou Province",
|
235
|
+
"53": "Yunnan Province",
|
236
|
+
"54": "Tibet Autonomous Region",
|
237
|
+
"61": "Shaanxi Province",
|
238
|
+
"62": "Gansu Province",
|
239
|
+
"63": "Qinghai Province",
|
240
|
+
"64": "Ningxia Hui Autonomous Region",
|
241
|
+
"65": "Xinjiang Uygur Autonomous Region",
|
242
|
+
"71": "Taiwan Province",
|
243
|
+
"81": "Hong Kong Special Administrative Region",
|
244
|
+
"82": "Macao Special Administrative Region",
|
245
|
+
}
|
246
|
+
}.freeze
|
247
|
+
|
248
|
+
def gb_mandate_suffix(prefix, mandate)
|
249
|
+
if prefix == "GB"
|
250
|
+
prefix += "/T" if mandate == "recommended"
|
251
|
+
prefix += "/Z" if mandate == "guide"
|
252
|
+
end
|
253
|
+
prefix
|
254
|
+
end
|
255
|
+
|
256
|
+
def mandate_suffix(prefix, mandate)
|
257
|
+
prefix += "/T" if mandate == "recommended"
|
258
|
+
prefix += "/Z" if mandate == "guide"
|
259
|
+
prefix
|
260
|
+
end
|
261
|
+
|
262
|
+
def standard_class(scope, prefix, mandate)
|
263
|
+
case scope
|
264
|
+
when "national"
|
265
|
+
NATIONAL&.dig(@lang, gb_mandate_suffix(prefix, mandate).to_sym,
|
266
|
+
:name) || "XXXX"
|
267
|
+
when "sector"
|
268
|
+
"#{@labels["PRC"]}#{SECTOR&.dig(@lang, prefix.to_sym,
|
269
|
+
:industry) || 'XXXX'}#{@labels["industry_standard"]}"
|
270
|
+
when "local"
|
271
|
+
"#{LOCAL&.dig(@lang, prefix.to_sym) || 'XXXX'}#{@labels["local_standard"]}"
|
272
|
+
when "enterprise"
|
273
|
+
issuer = get_metadata[:issuer]
|
274
|
+
"#{issuer}#{@labels["enterprise_standard"]}"
|
275
|
+
when "social" then @labels["social_standard"]
|
276
|
+
when "professional" then "PROFESSIONAL STANDARD" # TODO
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def standard_agency1(scope, prefix, mandate)
|
281
|
+
case scope
|
282
|
+
when "national"
|
283
|
+
NATIONAL&.dig(@lang, gb_mandate_suffix(prefix, mandate).to_sym,
|
284
|
+
:admin) || nil
|
285
|
+
when "sector"
|
286
|
+
SECTOR&.dig(@lang, prefix.to_sym, :admin) || nil
|
287
|
+
when "local"
|
288
|
+
LOCAL&.dig(@lang, prefix.to_sym) || nil
|
289
|
+
when "enterprise", "social"
|
290
|
+
get_metadata[:issuer] || nil
|
291
|
+
when "professional" then "PROFESSIONAL STANDARD" # TODO
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def standard_agency(scope, prefix, mandate)
|
296
|
+
case scope
|
297
|
+
when "national"
|
298
|
+
NATIONAL&.dig(@lang, gb_mandate_suffix(prefix, mandate).to_sym,
|
299
|
+
:admin) || nil
|
300
|
+
when "sector"
|
301
|
+
SECTOR&.dig(@lang, prefix.to_sym, :admin) || nil
|
302
|
+
when "local"
|
303
|
+
"#{LOCAL&.dig(@lang, prefix.to_sym) || 'XXXX'}#{@labels["local_issuer"]}"
|
304
|
+
when "enterprise", "social"
|
305
|
+
get_metadata[:issuer]
|
306
|
+
when "professional" then "PROFESSIONAL STANDARD" # TODO
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def gbtype_validate(root)
|
311
|
+
scope = root.at("//gbscope")&.text
|
312
|
+
prefix = root.at("//gbprefix")&.text
|
313
|
+
case scope
|
314
|
+
when "national"
|
315
|
+
NATIONAL.dig(@lang, prefix.to_sym) ||
|
316
|
+
warn("GB: #{prefix} is not a recognised national prefix")
|
317
|
+
when "sector"
|
318
|
+
SECTOR.dig(@lang, prefix.to_sym) ||
|
319
|
+
warn("GB: #{prefix} is not a recognised sector prefix")
|
320
|
+
when "local"
|
321
|
+
LOCAL.dig(@lang, prefix.to_sym) ||
|
322
|
+
warn("GB: #{prefix} is not a recognised local prefix")
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|