Module: Metanorma::StandardDocument::SectionXmlMapping

Defined in:
lib/metanorma/standard_document/block_attributes.rb

Overview

Shared XML mapping helpers for section-level elements. Extracts the common attribute/element mappings duplicated across ClauseSection, AnnexSection, and their flavor-specific subclasses.

Class Method Summary collapse

Class Method Details

.apply_annex_attributes(mapping) ⇒ Object

Common XML attribute mappings for annex sections.



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/metanorma/standard_document/block_attributes.rb', line 174

def self.apply_annex_attributes(mapping)
  mapping.map_attribute "id",            to: :id
  mapping.map_attribute "number",        to: :number
  mapping.map_attribute "obligation",    to: :obligation,
                                         render_empty: true
  mapping.map_attribute "unnumbered",    to: :unnumbered
  mapping.map_attribute "toc",           to: :toc
  mapping.map_attribute "anchor",        to: :anchor
  mapping.map_attribute "semx-id",       to: :semx_id
  mapping.map_attribute "autonum",       to: :autonum
  mapping.map_attribute "displayorder",  to: :displayorder
  mapping.map_attribute "inline-header", to: :inline_header
  mapping.map_attribute "language",      to: :language, render_empty: true
  mapping.map_attribute "script",        to: :script, render_empty: true
end

.apply_annex_elements(mapping) ⇒ Object

Common XML element mappings for annex sections.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/metanorma/standard_document/block_attributes.rb', line 191

def self.apply_annex_elements(mapping)
  mapping.map_element "title",                to: :title
  mapping.map_element "variant-title",        to: :variant_title
  mapping.map_element "fmt-title",            to: :fmt_title
  mapping.map_element "fmt-xref-label",       to: :fmt_xref_label

  BlockXmlMapping.apply_block_mappings(mapping)

  mapping.map_element "clause",               to: :clause
  mapping.map_element "appendix",             to: :appendix
  mapping.map_element "terms",                to: :terms
  mapping.map_element "definitions",          to: :definitions
  mapping.map_element "references",           to: :references
  mapping.map_element "floating-title",       to: :floating_title
  mapping.map_element "pagebreak",            to: :pagebreak
  mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
  mapping.map_element "fmt-annotation-end",   to: :fmt_annotation_end
end

.apply_clause_attributes(mapping) ⇒ Object

Common XML attribute mappings for clause sections.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/metanorma/standard_document/block_attributes.rb', line 133

def self.apply_clause_attributes(mapping)
  mapping.map_attribute "id",            to: :id
  mapping.map_attribute "anchor",        to: :anchor
  mapping.map_attribute "type",          to: :type
  mapping.map_attribute "number",        to: :number
  mapping.map_attribute "obligation",    to: :obligation
  mapping.map_attribute "inline-header", to: :inline_header
  mapping.map_attribute "unnumbered",    to: :unnumbered
  mapping.map_attribute "toc",           to: :toc
  mapping.map_attribute "class",         to: :class_attr
  mapping.map_attribute "semx-id",       to: :semx_id
  mapping.map_attribute "autonum",       to: :autonum
  mapping.map_attribute "displayorder",  to: :displayorder
end

.apply_clause_elements(mapping) ⇒ Object

Common XML element mappings for clause sections.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/metanorma/standard_document/block_attributes.rb', line 149

def self.apply_clause_elements(mapping)
  mapping.map_element "title",                to: :title
  mapping.map_element "variant-title",        to: :variant_title
  mapping.map_element "fmt-title",            to: :fmt_title
  mapping.map_element "fmt-xref-label",       to: :fmt_xref_label

  BlockXmlMapping.apply_block_mappings(mapping)

  mapping.map_element "amend",                to: :amend
  mapping.map_element "clause",               to: :clause
  mapping.map_element "terms",                to: :terms
  mapping.map_element "definitions",          to: :definitions
  mapping.map_element "references",           to: :references
  mapping.map_element "floating-title",       to: :floating_title
  mapping.map_element "form",                 to: :form
  mapping.map_element "requirement",          to: :requirement
  mapping.map_element "recommendation",       to: :recommendation
  mapping.map_element "permission",           to: :permission
  mapping.map_element "pagebreak",            to: :pagebreak
  mapping.map_element "bookmark",             to: :bookmark
  mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
  mapping.map_element "fmt-annotation-end",   to: :fmt_annotation_end
end

.apply_content_section_attributes(mapping) ⇒ Object

Common XML attribute/element mappings for ContentSection subclasses.



239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/metanorma/standard_document/block_attributes.rb', line 239

def self.apply_content_section_attributes(mapping)
  mapping.map_attribute "id",             to: :id
  mapping.map_attribute "anchor",         to: :anchor
  mapping.map_attribute "type",           to: :type
  mapping.map_attribute "number",         to: :number
  mapping.map_attribute "obligation",     to: :obligation
  mapping.map_attribute "inline-header",  to: :inline_header
  mapping.map_attribute "unnumbered",     to: :unnumbered
  mapping.map_attribute "toc",            to: :toc
  mapping.map_attribute "class",          to: :class_attr
  mapping.map_attribute "semx-id",        to: :semx_id
  mapping.map_attribute "autonum",        to: :autonum
  mapping.map_attribute "displayorder",   to: :displayorder
end

.apply_content_section_elements(mapping) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/metanorma/standard_document/block_attributes.rb', line 254

def self.apply_content_section_elements(mapping)
  mapping.map_element "title",                to: :title
  mapping.map_element "variant-title",        to: :variant_title
  mapping.map_element "fmt-title",            to: :fmt_title
  mapping.map_element "fmt-xref-label",       to: :fmt_xref_label

  BlockXmlMapping.apply_block_mappings(mapping)

  mapping.map_element "clause",               to: :subsection
  mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
  mapping.map_element "fmt-annotation-end",   to: :fmt_annotation_end
end

.apply_preface_attributes(mapping) ⇒ Object



233
234
235
236
# File 'lib/metanorma/standard_document/block_attributes.rb', line 233

def self.apply_preface_attributes(mapping)
  mapping.map_attribute "semx-id",      to: :semx_id
  mapping.map_attribute "displayorder", to: :displayorder
end

.apply_preface_elements(mapping) ⇒ Object

Common XML element/attribute mappings for preface containers.



225
226
227
228
229
230
231
# File 'lib/metanorma/standard_document/block_attributes.rb', line 225

def self.apply_preface_elements(mapping)
  mapping.map_element "abstract",          to: :abstract
  mapping.map_element "foreword",          to: :foreword
  mapping.map_element "introduction",      to: :introduction
  mapping.map_element "acknowledgements",  to: :acknowledgements
  mapping.map_element "executivesummary",  to: :executivesummary
end

.apply_sections_attributes(mapping) ⇒ Object



219
220
221
222
# File 'lib/metanorma/standard_document/block_attributes.rb', line 219

def self.apply_sections_attributes(mapping)
  mapping.map_attribute "semx-id",      to: :semx_id
  mapping.map_attribute "displayorder", to: :displayorder
end

.apply_sections_elements(mapping) ⇒ Object

Common XML element/attribute mappings for the sections container.



211
212
213
214
215
216
217
# File 'lib/metanorma/standard_document/block_attributes.rb', line 211

def self.apply_sections_elements(mapping)
  mapping.map_element "clause",         to: :clause
  mapping.map_element "terms",          to: :terms
  mapping.map_element "definitions",    to: :definitions
  mapping.map_element "floating-title", to: :floating_title
  mapping.map_element "references",     to: :references
end