From 9f7160bea95893c7b8c1d6ae51a752c275907017 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 8 Jan 2025 01:20:27 +0200 Subject: [PATCH] Presentation XML refactor, terms: https://github.com/metanorma/isodoc/issues/630 --- Gemfile.devel | 2 + lib/isodoc/ogc/presentation_xml_convert.rb | 18 +- spec/isodoc/section_spec.rb | 1621 +++++++++++--------- 3 files changed, 891 insertions(+), 750 deletions(-) create mode 100644 Gemfile.devel diff --git a/Gemfile.devel b/Gemfile.devel new file mode 100644 index 00000000..6ed58b49 --- /dev/null +++ b/Gemfile.devel @@ -0,0 +1,2 @@ +gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "feature/presentation-terms" +gem "mn-requirements", git: "https://github.com/metanorma/mn-requirements", branch: "main" diff --git a/lib/isodoc/ogc/presentation_xml_convert.rb b/lib/isodoc/ogc/presentation_xml_convert.rb index acb90627..3af112f4 100644 --- a/lib/isodoc/ogc/presentation_xml_convert.rb +++ b/lib/isodoc/ogc/presentation_xml_convert.rb @@ -145,7 +145,8 @@ def ol_depth(node) %i(arabic alphabet roman alphabet_upper roman_upper)[(idx - 1) % 5] end - def termsource1(elem) + # KILL + def termsource1xx(elem) while elem&.next_element&.name == "termsource" elem << "; #{to_xml(elem.next_element.remove.children)}" end @@ -153,6 +154,11 @@ def termsource1(elem) "#{to_xml(elem.children).strip}]") end + def termsource_label(elem, sources) + elem.replace(l10n("[#{@i18n.source}: " \ + "#{sources}]")) + end + def bibliography_bibitem_number_skip(bibitem) implicit_reference(bibitem) || bibitem.at(ns(".//docidentifier[@type = 'metanorma-ordinal']")) || @@ -181,13 +187,19 @@ def biblio_ref_entry_code(ordinal, ids, _id, standard, datefn, _bib) end def deprecates(elem) - elem << " #{@i18n.deprecated}" + elem.xpath(ns(".//semx[@element = 'deprecates']")).each do |s| + s.next = " #{@i18n.deprecated}" + end end def admits(elem) - elem << " #{@i18n.admitted}" + elem.xpath(ns(".//semx[@element = 'admitted']")).each do |s| + s.next = " #{@i18n.admitted}" + end end + def designation_boldface(desgn); end + def source_label(elem) labelled_ancestor(elem) and return #lbl = "#{lower2cap @i18n.sourcecode}" diff --git a/spec/isodoc/section_spec.rb b/spec/isodoc/section_spec.rb index 22aa2bb7..dcf25551 100644 --- a/spec/isodoc/section_spec.rb +++ b/spec/isodoc/section_spec.rb @@ -197,11 +197,11 @@ Terms, Definitions, Symbols and Abbreviated Terms - Term2 - Term2A - Term2B - Term2C - Term2D + Term2 + Term2A + Term2B + Term2C + Term2D 3.1 @@ -221,60 +221,124 @@ #{METANORMA_EXTENSION} - - Contents - - - - - Terms, Definitions, Symbols and Abbreviated Terms - - - 1 - . - - - - - Terms, Definitions, Symbols and Abbreviated Terms - - - Clause - 1 - - - - - 1 - . - 1 - . - - - - Clause - 1 - . - 1 - - Term2 - Term2A ALTERNATIVE - Term2B ALTERNATIVE - Term2C DEPRECATED - Term2D DEPRECATED - [SOURCE: - - - 3.1 - - ISO 7301:2011, Clause 3.1 - , modified — The term "cargo rice" is shown as deprecated, and - Note 1 to entry is not included here] - - - - - + + Contents + + + + + Terms, Definitions, Symbols and Abbreviated Terms + + + 1 + . + + + + + Terms, Definitions, Symbols and Abbreviated Terms + + + Clause + 1 + + + + + 1 + . + 1 + . + + + + Clause + 1 + . + 1 + + + + Term2 + + + +

+ Term2 +

+
+ + + Term2A + + + + + Term2B + + + +

+ Term2A +   + ALTERNATIVE +

+

+ Term2B +   + ALTERNATIVE +

+
+ + + Term2C + + + + + Term2D + + + +

+ Term2C +   + DEPRECATED +

+

+ Term2D +   + DEPRECATED +

+
+ + + + 3.1 + + + +

The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here

+
+
+ + [ + SOURCE: + + + + 3.1 + + ISO 7301:2011, Clause 3.1 + + , modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here + + ] + +
+
+
+ INPUT html = Xml::C14n.format(<<~OUTPUT) @@ -438,7 +502,7 @@ Terms, definitions, symbols and abbreviated terms Normal Terms - Term2 + Term2 Definitions @@ -474,7 +538,7 @@ Glossary Title - Glossary + Glossary @@ -483,13 +547,13 @@ Term Collection - Term + Term Term Collection 2 - Term + Term @@ -507,445 +571,454 @@ presxml = <<~OUTPUT - - A - B - - - - OGC - - - - - - DEF - - - technical-paper - - - #{METANORMA_EXTENSION} - - - - Contents - - - Abstract - - - I - . - - - - - Abstract - - - Abstract - -

XYZ

-
- - Executive Summary - - - II - . - - - - - Executive Summary - - - Executive Summary - -

Text

-
- - Keywords - - - III - . - - - - - Keywords - - - Keywords - -

The following are keywords to be used by search engines and document catalogues.

-

A, B

-
- - Preface - - - IV - . - - - - - Preface - - - Preface - -

This is a preamble

-
- - Security - - - V - . - - - - - Security - - - Security - -

Text

-
- - Submitting Organizations - - - VI - . - - - - - Submitting Organizations - - - Submitting Organizations - -

The following organizations submitted this Document to the Open Geospatial Consortium (OGC):

-
    -
  • OGC
  • -
  • DEF
  • -
-
- - Submitters - - - VII - . - - - - - Submitters - - - Submitters - -

ABC

-
- - Contributors - - - VIII - . - - - - - Contributors - - - Contributors - -

ABC

-
- - Dedication - - - IX - . - - - - - Dedication - - - Dedication - - - Note to readers - - - IX - . - A - . - - - - - Note to readers - - - Clause - IX - . - A - - - - - Acknowlegements - - - X - . - - - - - Acknowlegements - - - Acknowlegements - -

ABC

-
-
- - - Scope - - - 1 - . - - - - - Scope - - - Clause - 1 - -

Text

-
- - Conformance - - - 2 - . - - - - - Conformance - - - Clause - 2 - -

Text

-
- - Terms, definitions, symbols and abbreviated terms - - - 4 - . - - - - - Terms, definitions, symbols and abbreviated terms - - - Clause - 4 - - - Normal Terms - - - 4 - . - 1 - . - - - - - Normal Terms - - - Clause - 4 - . - 1 - - - - - 4 - . - 1 - . - 1 - . - - - - Clause - 4 - . - 1 - . - 1 - - Term2 - - - - Definitions - - - 4 - . - 2 - . - - - - - Definitions - - - Clause - 4 - . - 2 - -
-
Symbol
-
Definition
-
-
-
- - Definitions - - - 5 - . - - - - - Definitions - - - Clause - 5 - -
-
Symbol
-
Definition
-
-
- - Clause 4 - - - 6 - . - - - - - Clause 4 - - - Clause - 6 - - - Introduction - - - 6 - . - 1 - . - - - - - Introduction - - - Clause - 6 - . - 1 - - - - Clause 4.2 - - - 6 - . - 2 - . - - - - - Clause 4.2 - - - Clause - 6 - . - 2 - - - - - Normative References - - - 3 - . - - - - - Normative References - - - Clause - 3 - - -
+ + A + B + + + + OGC + + + + + + DEF + + + technical-paper + + + #{METANORMA_EXTENSION} + + + + Contents + + + Abstract + + + I + . + + + + + Abstract + + + Abstract + +

XYZ

+
+ + Executive Summary + + + II + . + + + + + Executive Summary + + + Executive Summary + +

Text

+
+ + Keywords + + + III + . + + + + + Keywords + + + Keywords + +

The following are keywords to be used by search engines and document catalogues.

+

A, B

+
+ + Preface + + + IV + . + + + + + Preface + + + Preface + +

This is a preamble

+
+ + Security + + + V + . + + + + + Security + + + Security + +

Text

+
+ + Submitting Organizations + + + VI + . + + + + + Submitting Organizations + + + Submitting Organizations + +

The following organizations submitted this Document to the Open Geospatial Consortium (OGC):

+
    +
  • OGC
  • +
  • DEF
  • +
+
+ + Submitters + + + VII + . + + + + + Submitters + + + Submitters + +

ABC

+
+ + Contributors + + + VIII + . + + + + + Contributors + + + Contributors + +

ABC

+
+ + Dedication + + + IX + . + + + + + Dedication + + + Dedication + + + Note to readers + + + IX + . + A + . + + + + + Note to readers + + + Clause + IX + . + A + + + + + Acknowlegements + + + X + . + + + + + Acknowlegements + + + Acknowlegements + +

ABC

+
+
+ + + Scope + + + 1 + . + + + + + Scope + + + Clause + 1 + +

Text

+
+ + Conformance + + + 2 + . + + + + + Conformance + + + Clause + 2 + +

Text

+
+ + Terms, definitions, symbols and abbreviated terms + + + 4 + . + + + + + Terms, definitions, symbols and abbreviated terms + + + Clause + 4 + + + Normal Terms + + + 4 + . + 1 + . + + + + + Normal Terms + + + Clause + 4 + . + 1 + + + + + 4 + . + 1 + . + 1 + . + + + + Clause + 4 + . + 1 + . + 1 + + + + Term2 + + + +

+ Term2 +

+
+
+
+ + Definitions + + + 4 + . + 2 + . + + + + + Definitions + + + Clause + 4 + . + 2 + +
+
Symbol
+
Definition
+
+
+
+ + Definitions + + + 5 + . + + + + + Definitions + + + Clause + 5 + +
+
Symbol
+
Definition
+
+
+ + Clause 4 + + + 6 + . + + + + + Clause 4 + + + Clause + 6 + + + Introduction + + + 6 + . + 1 + . + + + + + Introduction + + + Clause + 6 + . + 1 + + + + Clause 4.2 + + + 6 + . + 2 + . + + + + + Clause 4.2 + + + Clause + 6 + . + 2 + + + + + Normative References + + + 3 + . + + + + + Normative References + + + Clause + 3 + + +
OUTPUT presxml1 = <<~OUTPUT @@ -1060,7 +1133,16 @@ . 1 - Glossary + + + Glossary + + + +

+ Glossary +

+
@@ -1127,7 +1209,16 @@ . 1 - Term + + + Term + + + +

+ Term +

+
@@ -1169,7 +1260,16 @@ . 1 - Term + + + Term + + + +

+ Term +

+
@@ -1372,249 +1472,276 @@ .gsub(%r{.*}m, ""), ))).to be_equivalent_to Xml::C14n.format(output + output1) - presxml1 = <<~OUTPUT + presxml2 = <<~OUTPUT - - <strong>Annex</strong> - - - - - Annex - A - - -
- (normative) - -
-
- - Annex - -
- - Annex - A - - - Annex A.1 - - - A - . - 1 - . - - - - - Annex A.1 - - - Annex - A - . - 1 - - - Annex A.1a - - - A - . - 1 - . - 1 - . - - - - - Annex A.1a - - - Annex - A - . - 1 - . - 1 - - - -
- - - <strong>Glossary</strong> - - - - - Annex - B - - -
- (normative) - -
-
- - Glossary - -
- - Annex - B - - - - - - B - . - 1 - . - - - - Annex - B - . - 1 - - Glossary - - -
- - - <strong>Glossary</strong> - - - - - Annex - C - - -
- (normative) - -
-
- - Glossary - -
- - Annex - C - - - Term Collection - - - C - . - 1 - . - - - - - Term Collection - - - Annex - C - . - 1 - - - - - C - . - 1 - . - 1 - . - - - - Annex - C - . - 1 - . - 1 - - Term - - - - Term Collection 2 - - - C - . - 2 - . - - - - - Term Collection 2 - - - Annex - C - . - 2 - - - - - C - . - 2 - . - 1 - . - - - - Annex - C - . - 2 - . - 1 - - Term - - -
- - - Bibliography - - Bibliography - - - Bibliography Subsection - - Bibliography Subsection - - - - - + + <strong>Annex</strong> + + + + + Annex + A + + +
+ (normative) + +
+
+ + Annex + +
+ + Annex + A + + + Annex A.1 + + + A + . + 1 + . + + + + + Annex A.1 + + + Annex + A + . + 1 + + + Annex A.1a + + + A + . + 1 + . + 1 + . + + + + + Annex A.1a + + + Annex + A + . + 1 + . + 1 + + + + + + + <strong>Glossary</strong> + + + + + Annex + B + + +
+ (normative) + +
+
+ + Glossary + +
+ + Annex + B + + + + + + B + . + 1 + . + + + + Annex + B + . + 1 + + + + Glossary + + + +

+ Glossary +

+
+
+
+
+ + + <strong>Glossary</strong> + + + + + Annex + C + + +
+ (normative) + +
+
+ + Glossary + +
+ + Annex + C + + + Term Collection + + + C + . + 1 + . + + + + + Term Collection + + + Annex + C + . + 1 + + + + + C + . + 1 + . + 1 + . + + + + Annex + C + . + 1 + . + 1 + + + + Term + + + +

+ Term +

+
+
+
+ + Term Collection 2 + + + C + . + 2 + . + + + + + Term Collection 2 + + + Annex + C + . + 2 + + + + + C + . + 2 + . + 1 + . + + + + Annex + C + . + 2 + . + 1 + + + + Term + + + +

+ Term +

+
+
+
+
+ + + Bibliography + + Bibliography + + + Bibliography Subsection + + Bibliography Subsection + + + + + OUTPUT - output1 = <<~OUTPUT + output2 = <<~OUTPUT

Bibliography

@@ -1681,13 +1808,13 @@ xml.at("//xmlns:localized-strings").remove expect(Xml::C14n.format(strip_guid(xml.to_xml))) .to be_equivalent_to Xml::C14n.format( - presxml.sub("technical-paper", "engineering-report") + presxml1, + presxml.sub("technical-paper", "engineering-report") + presxml2, ) expect(Xml::C14n.format(strip_guid( IsoDoc::Ogc::HtmlConvert.new({}) .convert("test", pres_output, true) .gsub(%r{^.*.*}m, ""), - ))).to be_equivalent_to Xml::C14n.format(output + output1) + ))).to be_equivalent_to Xml::C14n.format(output + output2) end end