Skip to content

Commit 343f478

Browse files
committed
single base tag in metanorma: metanorma/metanorma#440
1 parent 1a532ea commit 343f478

12 files changed

+3102
-146
lines changed

Gemfile.devel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "fix/single-root-tag"

lib/metanorma/itu/isodoc.rng

+1-1
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ numbers</a:documentation>
12081208
</define>
12091209
<define name="standard-document">
12101210
<a:documentation>Representation of a standardisation document</a:documentation>
1211-
<element name="standard-document">
1211+
<element name="metanorma">
12121212
<ref name="Root-Attributes"/>
12131213
<ref name="bibdata">
12141214
<a:documentation>Bibliographic description of the document itself, expressed in the Relaton model</a:documentation>

lib/metanorma/itu/itu.rng

+27-30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<grammar ns='https://www.metanorma.org/ns/itu' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
2+
<grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
33
<!--
44
VERSION v1.2.1
55
Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
@@ -8,9 +8,6 @@
88
-->
99
<include href="relaton-itu.rng"/>
1010
<include href="isodoc.rng">
11-
<start>
12-
<ref name="itu"/>
13-
</start>
1411
<define name="OlAttr" combine="interleave">
1512
<optional>
1613
<attribute name="class">
@@ -85,31 +82,31 @@
8582
</zeroOrMore>
8683
</group>
8784
</define>
85+
<define name="standard-document">
86+
<element name="metanorma">
87+
<ref name="Root-Attributes"/>
88+
<ref name="bibdata"/>
89+
<zeroOrMore>
90+
<ref name="termdocsource"/>
91+
</zeroOrMore>
92+
<optional>
93+
<ref name="misccontainer"/>
94+
</optional>
95+
<optional>
96+
<ref name="boilerplate"/>
97+
</optional>
98+
<ref name="preface"/>
99+
<oneOrMore>
100+
<ref name="sections"/>
101+
</oneOrMore>
102+
<zeroOrMore>
103+
<ref name="annex"/>
104+
</zeroOrMore>
105+
<ref name="bibliography"/>
106+
<zeroOrMore>
107+
<ref name="indexsect"/>
108+
</zeroOrMore>
109+
</element>
110+
</define>
88111
</include>
89-
<define name="itu">
90-
<element name="itu-standard">
91-
<ref name="Root-Attributes"/>
92-
<ref name="bibdata"/>
93-
<zeroOrMore>
94-
<ref name="termdocsource"/>
95-
</zeroOrMore>
96-
<optional>
97-
<ref name="misccontainer"/>
98-
</optional>
99-
<optional>
100-
<ref name="boilerplate"/>
101-
</optional>
102-
<ref name="preface"/>
103-
<oneOrMore>
104-
<ref name="sections"/>
105-
</oneOrMore>
106-
<zeroOrMore>
107-
<ref name="annex"/>
108-
</zeroOrMore>
109-
<ref name="bibliography"/>
110-
<zeroOrMore>
111-
<ref name="indexsect"/>
112-
</zeroOrMore>
113-
</element>
114-
</define>
115112
</grammar>

spec/isodoc/i18n_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RSpec.describe Metanorma::Itu do
55
it "processes section names in French" do
66
presxml = <<~OUTPUT
7-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
7+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
88
<bibdata type="standard">
99
<title language="en" format="text/plain" type="main">An ITU Standard</title>
1010
<title language="fr" format="text/plain" type="main">Un Standard ITU</title>
@@ -309,7 +309,7 @@
309309
</references>
310310
</clause>
311311
</bibliography>
312-
</itu-standard>
312+
</metanorma>
313313
OUTPUT
314314

315315
html = <<~OUTPUT
@@ -420,7 +420,7 @@
420420

421421
it "processes section names in Chinese" do
422422
presxml = <<~OUTPUT
423-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
423+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
424424
<bibdata type="standard">
425425
<title language="en" format="text/plain" type="main">An ITU Standard</title>
426426
<title language="fr" format="text/plain" type="main">Un Standard ITU</title>
@@ -725,7 +725,7 @@
725725
</references>
726726
</clause>
727727
</bibliography>
728-
</itu-standard>
728+
</metanorma>
729729
OUTPUT
730730

731731
html = <<~OUTPUT
@@ -848,7 +848,7 @@
848848
it "processes editor clauses, two editors in French" do
849849
FileUtils.rm_f "test.html"
850850
input = <<~INPUT
851-
<itu-standard xmlns="http://riboseinc.com/isoxml">
851+
<metanorma xmlns="http://riboseinc.com/isoxml">
852852
<bibdata type="standard">
853853
<title language="en" format="text/plain" type="main">An ITU Standard</title>
854854
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -873,7 +873,7 @@
873873
<sections>
874874
<clause id="A"><p/></clause>
875875
</sections>
876-
</itu-standard>
876+
</metanorma>
877877
INPUT
878878
presxml = <<~OUTPUT
879879
<preface>

spec/isodoc/section_spec.rb

+28-28
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
it "processes annexes and appendixes" do
3333
input = <<~INPUT
34-
<itu-standard xmlns="http://riboseinc.com/isoxml">
34+
<metanorma xmlns="http://riboseinc.com/isoxml">
3535
<bibdata type="standard">
3636
<title language="en" format="text/plain" type="main">An ITU Standard</title>
3737
<docidentifier type="ITU">12345</docidentifier>
@@ -69,7 +69,7 @@
6969
<annex id="B10" obligation="informative"><title>Annex</title></annex>
7070
INPUT
7171
presxml = <<~OUTPUT
72-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
72+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
7373
<bibdata type="standard">
7474
<title language="en" format="text/plain" type="main">An ITU Standard</title>
7575
<docidentifier type="ITU">12345</docidentifier>
@@ -638,7 +638,7 @@
638638
<span class="fmt-obligation">(This appendix does not form an integral part of this Recommendation.)</span>
639639
</p>
640640
</annex>
641-
</itu-standard>
641+
</metanorma>
642642
OUTPUT
643643
html = <<~OUTPUT
644644
#{HTML_HDR}
@@ -765,7 +765,7 @@
765765

766766
it "processes section names" do
767767
presxml = <<~OUTPUT
768-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
768+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
769769
<bibdata type="standard">
770770
<title language="en" format="text/plain" type="main">An ITU Standard</title>
771771
<title language="fr" format="text/plain" type="main">Un Standard ITU</title>
@@ -1071,7 +1071,7 @@
10711071
</references>
10721072
</clause>
10731073
</bibliography>
1074-
</itu-standard>
1074+
</metanorma>
10751075
OUTPUT
10761076

10771077
html = <<~OUTPUT
@@ -1309,7 +1309,7 @@
13091309
it "post-processes section names (Word)" do
13101310
FileUtils.rm_f "test.doc"
13111311
IsoDoc::Itu::WordConvert.new({}).convert("test", <<~INPUT, false)
1312-
<itu-standard xmlns="http://riboseinc.com/isoxml">
1312+
<metanorma xmlns="http://riboseinc.com/isoxml">
13131313
<bibdata type="standard">
13141314
<title language="en" format="text/plain" type="main">An ITU Standard</title>
13151315
<docidentifier type="ITU">12345</docidentifier>
@@ -1353,7 +1353,7 @@
13531353
</clause>
13541354
</clause>
13551355
</annex>
1356-
</itu-standard>
1356+
</metanorma>
13571357
INPUT
13581358
expect(File.exist?("test.doc")).to be true
13591359
html = File.read("test.doc", encoding: "UTF-8")
@@ -1404,7 +1404,7 @@
14041404
FileUtils.rm_f "test.html"
14051405
FileUtils.rm_f "test.doc"
14061406
input = <<~INPUT
1407-
<itu-standard xmlns="http://riboseinc.com/isoxml">
1407+
<metanorma xmlns="http://riboseinc.com/isoxml">
14081408
<bibdata type="standard">
14091409
<title language="en" format="text/plain" type="main">An ITU Standard</title>
14101410
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -1428,11 +1428,11 @@
14281428
<formula id="V"><stem type="AsciiMath">r = 1 %</stem></formula>
14291429
</clause>
14301430
</annex>
1431-
</itu-standard>
1431+
</metanorma>
14321432
INPUT
14331433

14341434
presxml = <<~OUTPUT
1435-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
1435+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
14361436
<bibdata type="standard">
14371437
<title language="en" format="text/plain" type="main">An ITU Standard</title>
14381438
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -1563,7 +1563,7 @@
15631563
</formula>
15641564
</clause>
15651565
</annex>
1566-
</itu-standard>
1566+
</metanorma>
15671567
OUTPUT
15681568
pres_output = IsoDoc::Itu::PresentationXMLConvert
15691569
.new(presxml_options)
@@ -1741,7 +1741,7 @@
17411741

17421742
it "processes unnumbered clauses" do
17431743
input = <<~INPUT
1744-
<itu-standard xmlns="http://riboseinc.com/isoxml">
1744+
<metanorma xmlns="http://riboseinc.com/isoxml">
17451745
<bibdata type="standard">
17461746
<title language="en" format="text/plain" type="main">An ITU Standard</title>
17471747
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -1758,10 +1758,10 @@
17581758
<clause unnumbered="true" id="A"><p>Text</p></clause>
17591759
<clause id="B"><title>First Clause</title></clause>
17601760
</sections>
1761-
</itu-standard>
1761+
</metanorma>
17621762
INPUT
17631763
presxml = <<~OUTPUT
1764-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
1764+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
17651765
<bibdata type="standard">
17661766
<title language="en" format="text/plain" type="main">An ITU Standard</title>
17671767
<title language="en" format="text/plain" type="resolution">RESOLUTION (, )</title>
@@ -1798,7 +1798,7 @@
17981798
</fmt-title>
17991799
</clause>
18001800
</sections>
1801-
</itu-standard>
1801+
</metanorma>
18021802
OUTPUT
18031803
expect(Xml::C14n.format(strip_guid(IsoDoc::Itu::PresentationXMLConvert.new(presxml_options)
18041804
.convert("test", input, true)
@@ -1808,7 +1808,7 @@
18081808

18091809
it "processes bis, ter etc clauses" do
18101810
input = <<~INPUT
1811-
<itu-standard xmlns="http://riboseinc.com/isoxml">
1811+
<metanorma xmlns="http://riboseinc.com/isoxml">
18121812
<bibdata type="standard">
18131813
<title language="en" format="text/plain" type="main">An ITU Standard</title>
18141814
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -1831,10 +1831,10 @@
18311831
</clause>
18321832
<clause id="E" number="10bit"><title>Non-Clause</title></clause>
18331833
</sections>
1834-
</itu-standard>
1834+
</metanorma>
18351835
INPUT
18361836
presxml = <<~OUTPUT
1837-
<itu-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
1837+
<metanorma xmlns="http://riboseinc.com/isoxml" type="presentation">
18381838
<bibdata type="standard">
18391839
<title language="en" format="text/plain" type="main">An ITU Standard</title>
18401840
<title language="en" format="text/plain" type="resolution">RESOLUTION (, )</title>
@@ -1966,7 +1966,7 @@
19661966
</fmt-title>
19671967
</clause>
19681968
</sections>
1969-
</itu-standard>
1969+
</metanorma>
19701970
OUTPUT
19711971
expect(Xml::C14n.format(strip_guid(IsoDoc::Itu::PresentationXMLConvert.new(presxml_options)
19721972
.convert("test", input, true)
@@ -1976,7 +1976,7 @@
19761976

19771977
it "processes editor clauses, one editor" do
19781978
input = <<~INPUT
1979-
<itu-standard xmlns="http://riboseinc.com/isoxml">
1979+
<metanorma xmlns="http://riboseinc.com/isoxml">
19801980
<bibdata type="standard">
19811981
<title language="en" format="text/plain" type="main">An ITU Standard</title>
19821982
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -2003,7 +2003,7 @@
20032003
<sections>
20042004
<clause id="A"/>
20052005
</sections>
2006-
</itu-standard>
2006+
</metanorma>
20072007
INPUT
20082008
presxml = <<~OUTPUT
20092009
<preface>
@@ -2039,7 +2039,7 @@
20392039

20402040
it "processes editor clauses, two editors" do
20412041
input = <<~INPUT
2042-
<itu-standard xmlns="http://riboseinc.com/isoxml">
2042+
<metanorma xmlns="http://riboseinc.com/isoxml">
20432043
<bibdata type="standard">
20442044
<title language="en" format="text/plain" type="main">An ITU Standard</title>
20452045
<title language="en" format="text/plain" type="subtitle">Subtitle</title>
@@ -2064,7 +2064,7 @@
20642064
<sections>
20652065
<clause id="A"><p/></clause>
20662066
</sections>
2067-
</itu-standard>
2067+
</metanorma>
20682068
INPUT
20692069
presxml = <<~OUTPUT
20702070
<preface>
@@ -2106,7 +2106,7 @@
21062106
"html"),
21072107
)
21082108
input = <<~INPUT
2109-
<itu-standard xmlns='https://www.metanorma.org/ns/itu' type='semantic'>
2109+
<metanorma xmlns='https://www.metanorma.org/ns/itu' type='semantic'>
21102110
<bibdata type='standard'>
21112111
<title language='en' format='text/plain' type='main'>Main Title</title>
21122112
<title language='fr' format='text/plain' type='main'>Titre Principal</title>
@@ -2271,10 +2271,10 @@
22712271
<p id="_a42297b2-5f04-5da9-64c2-7e92670d5cad">TEXT 9</p>
22722272
</clause>
22732273
</annex>
2274-
</itu-standard>
2274+
</metanorma>
22752275
INPUT
22762276
presxml = <<~OUTPUT
2277-
<itu-standard>
2277+
<metanorma>
22782278
<preface>
22792279
<clause unnumbered="true" type="contribution-metadata" displayorder="1">
22802280
<table class="contribution-metadata" unnumbered="true" width="100%">
@@ -2564,13 +2564,13 @@
25642564
</tbody>
25652565
</table>
25662566
</annex>
2567-
</itu-standard>
2567+
</metanorma>
25682568
OUTPUT
25692569

25702570
xml = Nokogiri::XML(IsoDoc::Itu::PresentationXMLConvert.new(presxml_options)
25712571
.convert("test", input, true))
25722572
xml = xml.xpath("//xmlns:preface | //xmlns:sections | //xmlns:annex").to_xml
2573-
expect(Xml::C14n.format(strip_guid("<itu-standard>#{xml}</itu-standard>")))
2573+
expect(Xml::C14n.format(strip_guid("<metanorma>#{xml}</itu-standard>")))
25742574
.to be_equivalent_to Xml::C14n.format(presxml)
25752575

25762576
presxml = <<~OUTPUT

0 commit comments

Comments
 (0)