Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/single root tag #289

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "fix/single-root-tag"
gem "metanorma-iso", git: "https://github.com/metanorma/metanorma-iso", branch: "fix/single-root-tag"
2 changes: 1 addition & 1 deletion lib/metanorma/jis/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
63 changes: 30 additions & 33 deletions lib/metanorma/jis/isostandard.rng
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
default namespace isostandard = "https://www.metanorma.com/ns/iso"
-->
<include href="isodoc.rng">
<start>
<ref name="iso-standard"/>
</start>
<define name="sections">
<element name="sections">
<zeroOrMore>
Expand Down Expand Up @@ -238,38 +235,38 @@
</oneOrMore>
</choice>
</define>
<!--
We display the Normative References between scope and terms; but to keep the
grammar simple, we keep the references together
-->
<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>
<!-- end overrides -->
<!--
We display the Normative References between scope and terms; but to keep the
grammar simple, we keep the references together
-->
<define name="iso-standard">
<element name="iso-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>
<define name="clause-hanging-paragraph-with-footnote">
<element name="clause">
<optional>
Expand Down
71 changes: 34 additions & 37 deletions lib/metanorma/jis/jis.rng
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns='https://www.metanorma.org/ns/jis' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<grammar ns='https://www.metanorma.org/ns/standoc' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!--
VERSION v1.2.1
default namespace = "https://www.metanorma.com/ns/jis"
-->
<include href="relaton-jis.rng"/>
<include href="isostandard.rng">
<start>
<ref name="jis-standard"/>
</start>
<define name="annex">
<element name="annex">
<optional>
Expand All @@ -19,6 +16,39 @@
<ref name="Annex-Section"/>
</element>
</define>
<!--
We display the Normative References between scope and terms; but to keep the
grammar simple, we keep the references together
-->
<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>
<optional>
<ref name="colophon"/>
</optional>
</element>
</define>
</include>
<!-- end overrides -->
<define name="floating-section-title">
Expand All @@ -34,37 +64,4 @@
</zeroOrMore>
</element>
</define>
<!--
We display the Normative References between scope and terms; but to keep the
grammar simple, we keep the references together
-->
<define name="jis-standard">
<element name="jis-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>
<optional>
<ref name="colophon"/>
</optional>
</element>
</define>
</grammar>
38 changes: 19 additions & 19 deletions spec/metanorma/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
:investigative-committee: 日本産業標準調査会 標準第一部会
INPUT
output = <<~OUTPUT
<jis-standard type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/jis">
<metanorma type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/standoc">
<bibdata type="standard">
<title language="en" format="text/plain" type="main">Introduction — Main Title — Title — Title Part</title>
<title language="en" format="text/plain" type="title-intro">Introduction</title>
Expand Down Expand Up @@ -215,7 +215,7 @@
</feedback-statement>
</boilerplate>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
xml.at("//xmlns:metanorma-extension")&.remove
Expand All @@ -228,7 +228,7 @@
))
xml.at("//xmlns:metanorma-extension")&.remove
output = <<~OUTPUT
<jis-standard type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/jis">
<metanorma type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/standoc">
<bibdata type="standard">
<title language="en" format="text/plain" type="main">Introduction — Main Title — Title — Title Part</title>
<title language="en" format="text/plain" type="title-intro">Introduction</title>
Expand Down Expand Up @@ -340,7 +340,7 @@
</feedback-statement>
</boilerplate>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(xml.to_xml)))
.to be_equivalent_to Xml::C14n.format(output)
Expand All @@ -363,7 +363,7 @@
:publisher-abbr: Publisher Abbrev
INPUT
output = <<~OUTPUT
<jis-standard type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/jis">
<metanorma type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/standoc">
<bibdata type="standard">
<docidentifier primary="true" type="JIS">1000:#{Date.today.year}</docidentifier>
<docnumber>1000</docnumber>
Expand Down Expand Up @@ -430,7 +430,7 @@
</feedback-statement>
</boilerplate>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
xml.at("//xmlns:metanorma-extension")&.remove
expect(Xml::C14n.format(strip_guid(xml.to_xml)))
Expand Down Expand Up @@ -460,7 +460,7 @@

INPUT
output = <<~OUTPUT
<jis-standard type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/jis">
<metanorma type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/standoc">
<bibdata type="standard">
<docidentifier primary="true" type="JIS">TR 1000:#{Date.today.year}</docidentifier>
<docnumber>1000</docnumber>
Expand Down Expand Up @@ -556,7 +556,7 @@
</feedback-statement>
</boilerplate>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
xml.at("//xmlns:metanorma-extension")&.remove
Expand Down Expand Up @@ -591,7 +591,7 @@
:doctype: technical-specification
INPUT
output = <<~OUTPUT
<jis-standard type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/jis">
<metanorma type="semantic" version="#{Metanorma::Jis::VERSION}" xmlns="https://www.metanorma.org/ns/standoc">
<bibdata type="standard">
<docidentifier primary="true" type="JIS">TS 1000:#{Date.today.year}</docidentifier>
<docnumber>1000</docnumber>
Expand Down Expand Up @@ -642,7 +642,7 @@
</ext>
</bibdata>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
xml.at("//xmlns:metanorma-extension")&.remove
xml.at("//xmlns:boilerplate")&.remove
Expand Down Expand Up @@ -719,7 +719,7 @@
:copyright-holder: Copyright Holder
INPUT
output = <<~OUTPUT
<jis-standard xmlns="https://www.metanorma.org/ns/jis" type="semantic" version="#{Metanorma::Jis::VERSION}">
<metanorma xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Jis::VERSION}">
<bibdata type="standard">
<title language="en" format="text/plain" type="main">Introduction — Main Title — Title — Title Part</title>
<title language="en" format="text/plain" type="title-intro">Introduction</title>
Expand Down Expand Up @@ -793,7 +793,7 @@
</ext>
</bibdata>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
xml.at("//xmlns:metanorma-extension")&.remove
xml.at("//xmlns:boilerplate")&.remove
Expand All @@ -817,7 +817,7 @@
:copyright-year: 2022
INPUT
output = <<~OUTPUT
<jis-standard xmlns="https://www.metanorma.org/ns/jis" type="semantic" version="#{Metanorma::Jis::VERSION}">
<metanorma xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Jis::VERSION}">
<bibdata type="standard">
<docidentifier primary="true" type="JIS">Z 1000-1:1980/AMD 3:2022</docidentifier>
<docnumber>1000</docnumber>
Expand Down Expand Up @@ -871,7 +871,7 @@
</ext>
</bibdata>
<sections> </sections>
</jis-standard>
</metanorma>
OUTPUT
xml.at("//xmlns:metanorma-extension")&.remove
xml.at("//xmlns:boilerplate")&.remove
Expand Down Expand Up @@ -1009,7 +1009,7 @@
</example>
</clause>
</sections>
</jis-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 @@ -1083,7 +1083,7 @@
</example>
</clause>
</sections>
</jis-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 @@ -1153,7 +1153,7 @@
</p>
</clause>
</sections>
</jis-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to Xml::C14n.format(output)
Expand All @@ -1179,7 +1179,7 @@
<annex id="_" commentary="true" inline-header="false" obligation="informative">
<title>Commentary</title>
</annex>
</jis-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 @@ -1209,7 +1209,7 @@
</li>
</ol>
</sections>
</jis-standard>
</metanorma>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to Xml::C14n.format(output)
Expand Down
2 changes: 1 addition & 1 deletion spec/metanorma/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
#{BLANK_HDR}
#{BOILERPLATE}
<sections/>
</jis-standard>
</metanorma>
OUTPUT
expect(strip_guid(Xml::C14n.format(processor.input_to_isodoc(input, nil))))
.to be_equivalent_to Xml::C14n.format(output)
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def boilerplate_read(file)

BLANK_HDR = <<~"HDR".freeze
<?xml version="1.0" encoding="UTF-8"?>
<jis-standard xmlns="https://www.metanorma.org/ns/jis" type="semantic" version="#{Metanorma::Jis::VERSION}">
<metanorma xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Jis::VERSION}">
<bibdata type="standard">
<docidentifier primary="true" type="JIS">0:#{Date.today.year}</docidentifier>
<docnumber>0</docnumber>
Expand Down