Skip to content

Commit

Permalink
single base tag in metanorma: metanorma/metanorma#440
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Feb 4, 2025
1 parent 247ee9f commit 4b9f957
Show file tree
Hide file tree
Showing 10 changed files with 946 additions and 948 deletions.
1 change: 1 addition & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "fix/single-root-tag"
57 changes: 27 additions & 30 deletions lib/metanorma/ieee/ieee.rng
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns='https://www.metanorma.org/ns/ieee' xmlns="http://relaxng.org/ns/structure/1.0">
<grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0">
<!--
VERSION v1.2.1
Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
Expand All @@ -8,9 +8,6 @@
-->
<include href="relaton-ieee.rng"/>
<include href="isodoc.rng">
<start>
<ref name="ieee-standard"/>
</start>
<define name="sections">
<element name="sections">
<optional>
Expand All @@ -27,31 +24,31 @@
</oneOrMore>
</element>
</define>
<define name="standard-document">
<element name="metanorma">
<ref name="Root-Attributes"/>
<ref name="bibdata"/>
<zeroOrMore>
<ref name="termdocsource"/>
</zeroOrMore>
<optional>
<ref name="misccontainer"/>
</optional>
<optional>
<ref name="boilerplate"/>
</optional>
<ref name="preface"/>
<oneOrMore>
<ref name="sections"/>
</oneOrMore>
<zeroOrMore>
<ref name="annex"/>
</zeroOrMore>
<ref name="bibliography"/>
<zeroOrMore>
<ref name="indexsect"/>
</zeroOrMore>
</element>
</define>
</include>
<define name="ieee-standard">
<element name="ieee-standard">
<ref name="Root-Attributes"/>
<ref name="bibdata"/>
<zeroOrMore>
<ref name="termdocsource"/>
</zeroOrMore>
<optional>
<ref name="misccontainer"/>
</optional>
<optional>
<ref name="boilerplate"/>
</optional>
<ref name="preface"/>
<oneOrMore>
<ref name="sections"/>
</oneOrMore>
<zeroOrMore>
<ref name="annex"/>
</zeroOrMore>
<ref name="bibliography"/>
<zeroOrMore>
<ref name="indexsect"/>
</zeroOrMore>
</element>
</define>
</grammar>
2 changes: 1 addition & 1 deletion lib/metanorma/ieee/isodoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ numbers</a:documentation>
</define>
<define name="standard-document">
<a:documentation>Representation of a standardisation document</a:documentation>
<element name="standard-document">
<element name="metanorma">
<ref name="Root-Attributes"/>
<ref name="bibdata">
<a:documentation>Bibliographic description of the document itself, expressed in the Relaton model</a:documentation>
Expand Down
8 changes: 4 additions & 4 deletions spec/metanorma/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
output = <<~OUTPUT
#{@blank_hdr}
<sections/>
</ieee-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to Xml::C14n.format(output)
Expand All @@ -33,7 +33,7 @@
output = <<~OUTPUT
#{@blank_hdr}
<sections/>
</ieee-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to Xml::C14n.format(output)
Expand Down Expand Up @@ -672,7 +672,7 @@
<indexsect id='_' type='thematic'>
<title>Thematic Index</title>
</indexsect>
</ieee-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS)
.sub(%r{<boilerplate>.*</boilerplate>}m, ""))))
Expand Down Expand Up @@ -924,7 +924,7 @@
<indexsect id='_' type='thematic'>
<title>Thematic Index</title>
</indexsect>
</ieee-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS)
.sub(%r{<boilerplate>.*</boilerplate>}m, ""))))
Expand Down
28 changes: 14 additions & 14 deletions spec/metanorma/cleanup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,13 @@
== Clause 1
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<clause id='_' inline-header='false' obligation='normative'>
<title>Clause 1</title>
</clause>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.xpath("//xmlns:bibdata | //xmlns:metanorma-extension").each(&:remove)
Expand Down Expand Up @@ -710,7 +710,7 @@
* [[[ABC,DEF]]]
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<preface>
<introduction id='_' obligation='informative'>
<title>Introduction</title>
Expand Down Expand Up @@ -755,7 +755,7 @@
</bibitem>
</references>
</bibliography>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.at("//xmlns:bibdata").remove
Expand All @@ -780,7 +780,7 @@
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<note id='boilerplate_front' type="boilerplate">
<p id='_'>
Expand Down Expand Up @@ -829,7 +829,7 @@
<title>Clause</title>
</clause>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.at("//xmlns:bibdata").remove
Expand All @@ -855,7 +855,7 @@
* [[[ABC,DEF]]]
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections> </sections>
<annex id='_' inline-header='false' obligation='normative'>
<title>Appendix C</title>
Expand All @@ -868,7 +868,7 @@
</bibitem>
</references>
</annex>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.at("//xmlns:bibdata").remove
Expand Down Expand Up @@ -896,7 +896,7 @@
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<clause id='_' type='overview' inline-header='false' obligation='normative'>
<title>Overview</title>
Expand All @@ -917,7 +917,7 @@
<title>Overview</title>
</clause>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.at("//xmlns:bibdata").remove
Expand Down Expand Up @@ -950,7 +950,7 @@
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<clause id='_' type='overview' inline-header='false' obligation='normative'>
<title>Overview</title>
Expand Down Expand Up @@ -983,7 +983,7 @@
<title>Overview</title>
</clause>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.at("//xmlns:bibdata").remove
Expand Down Expand Up @@ -1383,7 +1383,7 @@
Text
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<preface>
<abstract id='_'>
<title>Abstract</title>
Expand Down Expand Up @@ -1424,7 +1424,7 @@
</clause>
</clause>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
ret.xpath("//xmlns:bibdata | //xmlns:metanorma-extension").each(&:remove)
Expand Down
6 changes: 3 additions & 3 deletions spec/metanorma/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
processor = registry.find_processor(:ieee)

inputxml = <<~INPUT
<ieee-standard xmlns="http://riboseinc.com/isoxml">
<metanorma xmlns="http://riboseinc.com/isoxml">
<sections>
<terms id="H" obligation="normative" displayorder="1"><fmt-title>Terms</fmt-title>
<term id="J">
Expand All @@ -17,7 +17,7 @@
</terms>
<preface/>
</sections>
</ieee-standard>
</metanorma>
INPUT

it "registers against metanorma" do
Expand All @@ -41,7 +41,7 @@
output = <<~OUTPUT
#{blank_hdr_gen}
<sections/>
</ieee-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(processor.input_to_isodoc(input, nil))))
.to be_equivalent_to Xml::C14n.format(output)
Expand Down
10 changes: 5 additions & 5 deletions spec/metanorma/refs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections/>
<bibliography>
<references id="_" normative="false" obligation="informative">
Expand Down Expand Up @@ -411,7 +411,7 @@
</bibitem>
</references>
</bibliography>
</ieee-standard>
</metanorma>
OUTPUT
out = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
out.xpath("//xmlns:bibdata | //xmlns:boilerplate | //xmlns:note | " \
Expand Down Expand Up @@ -467,7 +467,7 @@
* [[[ref3,IEEE 802.1D-1990]]] REF2
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<preface>
<introduction id='_' obligation='informative'>
<title>Introduction</title>
Expand Down Expand Up @@ -514,7 +514,7 @@
</p>
</annex>
<bibliography/>
</ieee-standard>
</metanorma>
OUTPUT
out = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
out.xpath("//xmlns:bibdata | //xmlns:boilerplate | " \
Expand Down Expand Up @@ -955,7 +955,7 @@
</bibitem>
</references>
</bibliography>
</ieee-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to Xml::C14n.format(output)
Expand Down
12 changes: 6 additions & 6 deletions spec/metanorma/terms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<<ISO2191,section=1>>,
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<terms id='_' obligation='normative'>
<title>Definitions</title>
Expand Down Expand Up @@ -86,7 +86,7 @@
</term>
</terms>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
out = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
out.xpath("//xmlns:bibdata | //xmlns:boilerplate | //xmlns:references | " \
Expand Down Expand Up @@ -136,7 +136,7 @@
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<terms id='_' obligation='normative'>
<title>Definitions</title>
Expand Down Expand Up @@ -263,7 +263,7 @@
</term>
</terms>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
out = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
out.xpath("//xmlns:bibdata | //xmlns:boilerplate | //xmlns:references | " \
Expand All @@ -284,7 +284,7 @@
symbol:[thing1]
INPUT
output = <<~OUTPUT
<ieee-standard xmlns='https://www.metanorma.org/ns/ieee' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<metanorma xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Ieee::VERSION}'>
<sections>
<terms id='_' obligation='normative'>
<title>Definitions</title>
Expand Down Expand Up @@ -329,7 +329,7 @@
</term>
</terms>
</sections>
</ieee-standard>
</metanorma>
OUTPUT
out = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
out.xpath("//xmlns:bibdata | //xmlns:boilerplate | //xmlns:references | " \
Expand Down
Loading

0 comments on commit 4b9f957

Please sign in to comment.