sts 0.6.11 → 0.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +5 -3
  3. data/.github/workflows/release.yml +6 -10
  4. data/Gemfile +1 -0
  5. data/README.adoc +42 -0
  6. data/TODO.sts-refactor/00-overview.md +11 -19
  7. data/TODO.sts-refactor/03-namespace-coupling.md +40 -39
  8. data/TODO.sts-refactor/08-isoiec-profile.md +4 -4
  9. data/TODO.sts-refactor/10-test-coverage.md +2 -1
  10. data/lib/sts/iso_sts/addr_line.rb +77 -0
  11. data/lib/sts/iso_sts/address.rb +40 -0
  12. data/lib/sts/iso_sts/aff.rb +87 -0
  13. data/lib/sts/iso_sts/aff_alternatives.rb +18 -0
  14. data/lib/sts/iso_sts/alternatives.rb +45 -0
  15. data/lib/sts/iso_sts/anonymous.rb +19 -0
  16. data/lib/sts/iso_sts/article_title.rb +92 -0
  17. data/lib/sts/iso_sts/attrib.rb +30 -1
  18. data/lib/sts/iso_sts/author_comment.rb +32 -0
  19. data/lib/sts/iso_sts/award_id.rb +69 -0
  20. data/lib/sts/iso_sts/back.rb +0 -2
  21. data/lib/sts/iso_sts/bio.rb +111 -0
  22. data/lib/sts/iso_sts/body.rb +0 -2
  23. data/lib/sts/iso_sts/boxed_text.rb +51 -13
  24. data/lib/sts/iso_sts/chapter_title.rb +56 -0
  25. data/lib/sts/iso_sts/chem_struct.rb +102 -0
  26. data/lib/sts/iso_sts/chem_struct_wrap.rb +60 -0
  27. data/lib/sts/iso_sts/collab.rb +118 -0
  28. data/lib/sts/iso_sts/comment.rb +94 -0
  29. data/lib/sts/iso_sts/conf_date.rb +24 -0
  30. data/lib/sts/iso_sts/conf_loc.rb +24 -0
  31. data/lib/sts/iso_sts/conf_name.rb +24 -0
  32. data/lib/sts/iso_sts/conf_sponsor.rb +24 -0
  33. data/lib/sts/iso_sts/content_language.rb +0 -4
  34. data/lib/sts/iso_sts/contrib.rb +74 -0
  35. data/lib/sts/iso_sts/contrib_group.rb +45 -0
  36. data/lib/sts/iso_sts/custom_meta.rb +0 -1
  37. data/lib/sts/iso_sts/custom_meta_group.rb +2 -0
  38. data/lib/sts/iso_sts/date.rb +28 -0
  39. data/lib/sts/iso_sts/date_in_citation.rb +32 -0
  40. data/lib/sts/iso_sts/degrees.rb +24 -0
  41. data/lib/sts/iso_sts/disp_formula_group.rb +43 -0
  42. data/lib/sts/iso_sts/disp_quote.rb +50 -12
  43. data/lib/sts/iso_sts/element_citation.rb +203 -0
  44. data/lib/sts/iso_sts/elocation_id.rb +24 -0
  45. data/lib/sts/iso_sts/fig_group.rb +50 -0
  46. data/lib/sts/iso_sts/funding_source.rb +85 -0
  47. data/lib/sts/iso_sts/given_names.rb +20 -0
  48. data/lib/sts/iso_sts/glossary.rb +91 -0
  49. data/lib/sts/iso_sts/glyph_data.rb +32 -0
  50. data/lib/sts/iso_sts/glyph_ref.rb +17 -0
  51. data/lib/sts/iso_sts/gov.rb +52 -0
  52. data/lib/sts/iso_sts/graphic.rb +0 -2
  53. data/lib/sts/iso_sts/inline_supplementary_material.rb +78 -0
  54. data/lib/sts/iso_sts/isbn.rb +22 -0
  55. data/lib/sts/iso_sts/issn.rb +22 -0
  56. data/lib/sts/iso_sts/issue_id.rb +26 -0
  57. data/lib/sts/iso_sts/issue_part.rb +24 -0
  58. data/lib/sts/iso_sts/issue_title.rb +24 -0
  59. data/lib/sts/iso_sts/journal_id.rb +24 -0
  60. data/lib/sts/iso_sts/language.rb +0 -4
  61. data/lib/sts/iso_sts/license.rb +2 -1
  62. data/lib/sts/iso_sts/license_p.rb +90 -29
  63. data/lib/sts/iso_sts/media.rb +64 -0
  64. data/lib/sts/iso_sts/meta_name.rb +3 -0
  65. data/lib/sts/iso_sts/meta_value.rb +53 -6
  66. data/lib/sts/iso_sts/mixed_citation.rb +9 -9
  67. data/lib/sts/iso_sts/monospace.rb +2 -0
  68. data/lib/sts/iso_sts/name.rb +32 -0
  69. data/lib/sts/iso_sts/name_alternatives.rb +20 -0
  70. data/lib/sts/iso_sts/on_behalf_of.rb +50 -0
  71. data/lib/sts/iso_sts/open_access.rb +28 -0
  72. data/lib/sts/iso_sts/overline.rb +99 -0
  73. data/lib/sts/iso_sts/part_title.rb +56 -0
  74. data/lib/sts/iso_sts/patent.rb +26 -0
  75. data/lib/sts/iso_sts/person_group.rb +44 -0
  76. data/lib/sts/iso_sts/prefix.rb +24 -0
  77. data/lib/sts/iso_sts/price.rb +46 -0
  78. data/lib/sts/iso_sts/private_char.rb +28 -0
  79. data/lib/sts/iso_sts/ref.rb +8 -5
  80. data/lib/sts/iso_sts/related_article.rb +191 -0
  81. data/lib/sts/iso_sts/related_object.rb +182 -0
  82. data/lib/sts/iso_sts/role.rb +52 -0
  83. data/lib/sts/iso_sts/roman.rb +99 -0
  84. data/lib/sts/iso_sts/sans_serif.rb +99 -0
  85. data/lib/sts/iso_sts/sc.rb +2 -0
  86. data/lib/sts/iso_sts/series.rb +52 -0
  87. data/lib/sts/iso_sts/size.rb +24 -0
  88. data/lib/sts/iso_sts/source.rb +58 -0
  89. data/lib/sts/iso_sts/speaker.rb +42 -0
  90. data/lib/sts/iso_sts/speech.rb +34 -0
  91. data/lib/sts/iso_sts/standard_ref.rb +2 -0
  92. data/lib/sts/iso_sts/statement.rb +40 -0
  93. data/lib/sts/iso_sts/strike.rb +2 -0
  94. data/lib/sts/iso_sts/string_name.rb +36 -0
  95. data/lib/sts/iso_sts/subtitle.rb +96 -0
  96. data/lib/sts/iso_sts/suffix.rb +24 -0
  97. data/lib/sts/iso_sts/supplement.rb +73 -0
  98. data/lib/sts/iso_sts/supplementary_material.rb +108 -0
  99. data/lib/sts/iso_sts/surname.rb +20 -0
  100. data/lib/sts/iso_sts/table_wrap_group.rb +44 -0
  101. data/lib/sts/iso_sts/target.rb +52 -0
  102. data/lib/sts/iso_sts/term_display.rb +81 -0
  103. data/lib/sts/iso_sts/term_head.rb +27 -13
  104. data/lib/sts/iso_sts/term_sec.rb +1 -1
  105. data/lib/sts/iso_sts/textual_form.rb +56 -0
  106. data/lib/sts/iso_sts/trans_source.rb +58 -0
  107. data/lib/sts/iso_sts/trans_title.rb +96 -0
  108. data/lib/sts/iso_sts/underline.rb +2 -0
  109. data/lib/sts/iso_sts/uri.rb +2 -0
  110. data/lib/sts/iso_sts/verse_group.rb +38 -0
  111. data/lib/sts/iso_sts/verse_line.rb +69 -0
  112. data/lib/sts/iso_sts/volume_id.rb +26 -0
  113. data/lib/sts/iso_sts/volume_series.rb +24 -0
  114. data/lib/sts/iso_sts.rb +94 -9
  115. data/lib/sts/niso_sts/element_citation.rb +1 -2
  116. data/lib/sts/niso_sts/mixed_citation.rb +1 -2
  117. data/lib/sts/niso_sts/nlm_citation.rb +1 -2
  118. data/lib/sts/niso_sts/preformat.rb +16 -0
  119. data/lib/sts/niso_sts/section.rb +1 -2
  120. data/lib/sts/niso_sts/sup.rb +14 -0
  121. data/lib/sts/niso_sts/term.rb +15 -2
  122. data/lib/sts/niso_sts/title.rb +2 -0
  123. data/lib/sts/profiles/iso_iec/constraints.rb +14 -11
  124. data/lib/sts/profiles/iso_iec/id_scheme.rb +64 -0
  125. data/lib/sts/profiles/iso_iec/validator.rb +25 -0
  126. data/lib/sts/profiles/iso_iec.rb +1 -0
  127. data/lib/sts/profiles.rb +26 -0
  128. data/lib/sts/tbx_iso_tml/bold.rb +6 -0
  129. data/lib/sts/tbx_iso_tml/definition.rb +4 -0
  130. data/lib/sts/tbx_iso_tml/example.rb +14 -0
  131. data/lib/sts/tbx_iso_tml/italic.rb +6 -0
  132. data/lib/sts/tbx_iso_tml/note.rb +10 -0
  133. data/lib/sts/version.rb +1 -1
  134. data/lib/sts.rb +4 -0
  135. metadata +83 -2
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sts
4
+ module IsoSts
5
+ class VolumeSeries < Lutaml::Model::Serializable
6
+ attribute :id, :string
7
+ attribute :content_type, :string
8
+ attribute :specific_use, :string
9
+ attribute :xml_lang, :string
10
+ attribute :content, :string, collection: true
11
+
12
+ xml do
13
+ element "volume-series"
14
+ mixed_content
15
+
16
+ map_attribute "id", to: :id
17
+ map_attribute "content-type", to: :content_type
18
+ map_attribute "specific-use", to: :specific_use
19
+ map_attribute "xml:lang", to: :xml_lang
20
+ map_content to: :content
21
+ end
22
+ end
23
+ end
24
+ end
data/lib/sts/iso_sts.rb CHANGED
@@ -88,8 +88,6 @@ module Sts
88
88
  autoload :Label, "#{__dir__}/iso_sts/label"
89
89
  autoload :Title, "#{__dir__}/iso_sts/title"
90
90
  autoload :Bold, "#{__dir__}/iso_sts/bold"
91
- autoload :BoxedText, "#{__dir__}/iso_sts/boxed_text"
92
- autoload :DispQuote, "#{__dir__}/iso_sts/disp_quote"
93
91
  autoload :Italic, "#{__dir__}/iso_sts/italic"
94
92
  autoload :Monospace, "#{__dir__}/iso_sts/monospace"
95
93
  autoload :NamedContent, "#{__dir__}/iso_sts/named_content"
@@ -101,19 +99,12 @@ module Sts
101
99
  # Shared model foundations
102
100
  autoload :Abbrev, "#{__dir__}/iso_sts/abbrev"
103
101
  autoload :Annotation, "#{__dir__}/iso_sts/annotation"
104
- autoload :Attrib, "#{__dir__}/iso_sts/attrib"
105
102
  autoload :Country, "#{__dir__}/iso_sts/country"
106
- autoload :CustomMeta, "#{__dir__}/iso_sts/custom_meta"
107
- autoload :CustomMetaGroup, "#{__dir__}/iso_sts/custom_meta_group"
108
103
  autoload :Day, "#{__dir__}/iso_sts/day"
109
104
  autoload :Etal, "#{__dir__}/iso_sts/etal"
110
105
  autoload :Fax, "#{__dir__}/iso_sts/fax"
111
106
  autoload :InlineGraphic, "#{__dir__}/iso_sts/inline_graphic"
112
107
  autoload :Institution, "#{__dir__}/iso_sts/institution"
113
- autoload :License, "#{__dir__}/iso_sts/license"
114
- autoload :LicenseP, "#{__dir__}/iso_sts/license_p"
115
- autoload :MetaName, "#{__dir__}/iso_sts/meta_name"
116
- autoload :MetaValue, "#{__dir__}/iso_sts/meta_value"
117
108
  autoload :MilestoneEnd, "#{__dir__}/iso_sts/milestone_end"
118
109
  autoload :MilestoneStart, "#{__dir__}/iso_sts/milestone_start"
119
110
  autoload :Month, "#{__dir__}/iso_sts/month"
@@ -121,6 +112,100 @@ module Sts
121
112
  autoload :ObjectId, "#{__dir__}/iso_sts/object_id"
122
113
  autoload :Phone, "#{__dir__}/iso_sts/phone"
123
114
  autoload :Season, "#{__dir__}/iso_sts/season"
115
+
116
+ # Recursive content closure
117
+ autoload :AddrLine, "#{__dir__}/iso_sts/addr_line"
118
+ autoload :Address, "#{__dir__}/iso_sts/address"
119
+ autoload :Aff, "#{__dir__}/iso_sts/aff"
120
+ autoload :AffAlternatives, "#{__dir__}/iso_sts/aff_alternatives"
121
+ autoload :Alternatives, "#{__dir__}/iso_sts/alternatives"
122
+ autoload :Anonymous, "#{__dir__}/iso_sts/anonymous"
123
+ autoload :ArticleTitle, "#{__dir__}/iso_sts/article_title"
124
+ autoload :Attrib, "#{__dir__}/iso_sts/attrib"
125
+ autoload :AuthorComment, "#{__dir__}/iso_sts/author_comment"
126
+ autoload :Bio, "#{__dir__}/iso_sts/bio"
127
+ autoload :BoxedText, "#{__dir__}/iso_sts/boxed_text"
128
+ autoload :ChapterTitle, "#{__dir__}/iso_sts/chapter_title"
129
+ autoload :ChemStruct, "#{__dir__}/iso_sts/chem_struct"
130
+ autoload :ChemStructWrap, "#{__dir__}/iso_sts/chem_struct_wrap"
131
+ autoload :Collab, "#{__dir__}/iso_sts/collab"
132
+ autoload :Comment, "#{__dir__}/iso_sts/comment"
133
+ autoload :ConfDate, "#{__dir__}/iso_sts/conf_date"
134
+ autoload :ConfLoc, "#{__dir__}/iso_sts/conf_loc"
135
+ autoload :ConfName, "#{__dir__}/iso_sts/conf_name"
136
+ autoload :ConfSponsor, "#{__dir__}/iso_sts/conf_sponsor"
137
+ autoload :Contrib, "#{__dir__}/iso_sts/contrib"
138
+ autoload :ContribGroup, "#{__dir__}/iso_sts/contrib_group"
139
+ autoload :Date, "#{__dir__}/iso_sts/date"
140
+ autoload :DateInCitation, "#{__dir__}/iso_sts/date_in_citation"
141
+ autoload :Degrees, "#{__dir__}/iso_sts/degrees"
142
+ autoload :DispFormulaGroup, "#{__dir__}/iso_sts/disp_formula_group"
143
+ autoload :DispQuote, "#{__dir__}/iso_sts/disp_quote"
144
+ autoload :ElementCitation, "#{__dir__}/iso_sts/element_citation"
145
+ autoload :ElocationId, "#{__dir__}/iso_sts/elocation_id"
146
+ autoload :FigGroup, "#{__dir__}/iso_sts/fig_group"
147
+ autoload :GivenNames, "#{__dir__}/iso_sts/given_names"
148
+ autoload :Glossary, "#{__dir__}/iso_sts/glossary"
149
+ autoload :GlyphData, "#{__dir__}/iso_sts/glyph_data"
150
+ autoload :GlyphRef, "#{__dir__}/iso_sts/glyph_ref"
151
+ autoload :Gov, "#{__dir__}/iso_sts/gov"
152
+ autoload :InlineSupplementaryMaterial,
153
+ "#{__dir__}/iso_sts/inline_supplementary_material"
154
+ autoload :Isbn, "#{__dir__}/iso_sts/isbn"
155
+ autoload :Issn, "#{__dir__}/iso_sts/issn"
156
+ autoload :IssueId, "#{__dir__}/iso_sts/issue_id"
157
+ autoload :IssuePart, "#{__dir__}/iso_sts/issue_part"
158
+ autoload :IssueTitle, "#{__dir__}/iso_sts/issue_title"
159
+ autoload :JournalId, "#{__dir__}/iso_sts/journal_id"
160
+ autoload :Media, "#{__dir__}/iso_sts/media"
161
+ autoload :Name, "#{__dir__}/iso_sts/name"
162
+ autoload :NameAlternatives, "#{__dir__}/iso_sts/name_alternatives"
163
+ autoload :OnBehalfOf, "#{__dir__}/iso_sts/on_behalf_of"
164
+ autoload :Overline, "#{__dir__}/iso_sts/overline"
165
+ autoload :PartTitle, "#{__dir__}/iso_sts/part_title"
166
+ autoload :Patent, "#{__dir__}/iso_sts/patent"
167
+ autoload :PersonGroup, "#{__dir__}/iso_sts/person_group"
168
+ autoload :Prefix, "#{__dir__}/iso_sts/prefix"
169
+ autoload :PrivateChar, "#{__dir__}/iso_sts/private_char"
170
+ autoload :RelatedArticle, "#{__dir__}/iso_sts/related_article"
171
+ autoload :RelatedObject, "#{__dir__}/iso_sts/related_object"
172
+ autoload :Role, "#{__dir__}/iso_sts/role"
173
+ autoload :Roman, "#{__dir__}/iso_sts/roman"
174
+ autoload :SansSerif, "#{__dir__}/iso_sts/sans_serif"
175
+ autoload :Series, "#{__dir__}/iso_sts/series"
176
+ autoload :Size, "#{__dir__}/iso_sts/size"
177
+ autoload :Source, "#{__dir__}/iso_sts/source"
178
+ autoload :Speaker, "#{__dir__}/iso_sts/speaker"
179
+ autoload :Speech, "#{__dir__}/iso_sts/speech"
180
+ autoload :Statement, "#{__dir__}/iso_sts/statement"
181
+ autoload :StringName, "#{__dir__}/iso_sts/string_name"
182
+ autoload :Subtitle, "#{__dir__}/iso_sts/subtitle"
183
+ autoload :Suffix, "#{__dir__}/iso_sts/suffix"
184
+ autoload :Supplement, "#{__dir__}/iso_sts/supplement"
185
+ autoload :SupplementaryMaterial, "#{__dir__}/iso_sts/supplementary_material"
186
+ autoload :Surname, "#{__dir__}/iso_sts/surname"
187
+ autoload :TableWrapGroup, "#{__dir__}/iso_sts/table_wrap_group"
188
+ autoload :Target, "#{__dir__}/iso_sts/target"
189
+ autoload :TextualForm, "#{__dir__}/iso_sts/textual_form"
190
+ autoload :TransSource, "#{__dir__}/iso_sts/trans_source"
191
+ autoload :TransTitle, "#{__dir__}/iso_sts/trans_title"
192
+ autoload :VerseGroup, "#{__dir__}/iso_sts/verse_group"
193
+ autoload :VerseLine, "#{__dir__}/iso_sts/verse_line"
194
+ autoload :VolumeId, "#{__dir__}/iso_sts/volume_id"
195
+ autoload :VolumeSeries, "#{__dir__}/iso_sts/volume_series"
196
+
197
+ # Remaining namespace closure
198
+ autoload :AwardId, "#{__dir__}/iso_sts/award_id"
199
+ autoload :CustomMeta, "#{__dir__}/iso_sts/custom_meta"
200
+ autoload :CustomMetaGroup, "#{__dir__}/iso_sts/custom_meta_group"
201
+ autoload :FundingSource, "#{__dir__}/iso_sts/funding_source"
202
+ autoload :License, "#{__dir__}/iso_sts/license"
203
+ autoload :LicenseP, "#{__dir__}/iso_sts/license_p"
204
+ autoload :MetaName, "#{__dir__}/iso_sts/meta_name"
205
+ autoload :MetaValue, "#{__dir__}/iso_sts/meta_value"
206
+ autoload :OpenAccess, "#{__dir__}/iso_sts/open_access"
207
+ autoload :Price, "#{__dir__}/iso_sts/price"
208
+ autoload :TermDisplay, "#{__dir__}/iso_sts/term_display"
124
209
  autoload :TermHead, "#{__dir__}/iso_sts/term_head"
125
210
 
126
211
  # List elements
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Metrics/BlockLength, Metrics/MethodLength
3
+ # rubocop:disable-next Metrics/BlockLength, Metrics/MethodLength
4
4
  module Sts
5
5
  module NisoSts
6
6
  class ElementCitation < Lutaml::Model::Serializable
@@ -100,4 +100,3 @@ module Sts
100
100
  end
101
101
  end
102
102
  end
103
- # rubocop:enable Metrics/BlockLength, Metrics/MethodLength
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Metrics/BlockLength
3
+ # rubocop:disable-next Metrics/BlockLength
4
4
  module Sts
5
5
  module NisoSts
6
6
  class MixedCitation < Lutaml::Model::Serializable
@@ -140,4 +140,3 @@ module Sts
140
140
  end
141
141
  end
142
142
  end
143
- # rubocop:enable Metrics/BlockLength
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Metrics/BlockLength
3
+ # rubocop:disable-next Metrics/BlockLength
4
4
  module Sts
5
5
  module NisoSts
6
6
  class NlmCitation < Lutaml::Model::Serializable
@@ -100,4 +100,3 @@ module Sts
100
100
  end
101
101
  end
102
102
  end
103
- # rubocop:enable Metrics/BlockLength
@@ -16,6 +16,14 @@ module Sts
16
16
  attribute :underline, ::Sts::NisoSts::Underline, collection: true
17
17
  attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
18
18
  attribute :std, ::Sts::NisoSts::ReferenceStandard, collection: true
19
+ attribute :xref, ::Sts::TbxIsoTml::Xref, collection: true
20
+ attribute :sub, ::Sts::NisoSts::Sub, collection: true
21
+ attribute :sup, ::Sts::NisoSts::Sup, collection: true
22
+ attribute :sc, ::Sts::NisoSts::Sc, collection: true
23
+ attribute :monospace, ::Sts::NisoSts::Monospace, collection: true
24
+ attribute :ext_link, ::Sts::NisoSts::ExtLink, collection: true
25
+ attribute :inline_formula, ::Sts::NisoSts::InlineFormula, collection: true
26
+ attribute :break, ::Sts::NisoSts::Break, collection: true
19
27
 
20
28
  xml do
21
29
  element "preformat"
@@ -34,6 +42,14 @@ module Sts
34
42
  map_element "underline", to: :underline
35
43
  map_element "styled-content", to: :styled_content
36
44
  map_element "std", to: :std
45
+ map_element "xref", to: :xref
46
+ map_element "sub", to: :sub
47
+ map_element "sup", to: :sup
48
+ map_element "sc", to: :sc
49
+ map_element "monospace", to: :monospace
50
+ map_element "ext-link", to: :ext_link
51
+ map_element "inline-formula", to: :inline_formula
52
+ map_element "break", to: :break
37
53
  end
38
54
  end
39
55
  end
@@ -45,7 +45,7 @@ module Sts
45
45
  collection: true
46
46
  attribute :fn, ::Sts::NisoSts::Fn, collection: true
47
47
 
48
- # rubocop:disable Metrics/BlockLength
48
+ # rubocop:disable-next Metrics/BlockLength
49
49
  xml do
50
50
  element "sec"
51
51
  ordered
@@ -87,7 +87,6 @@ module Sts
87
87
  map_element "non-normative-note", to: :non_normative_note
88
88
  map_element "non-normative-example", to: :non_normative_example
89
89
  end
90
- # rubocop:enable Metrics/BlockLength
91
90
  end
92
91
  end
93
92
  end
@@ -12,6 +12,13 @@ module Sts
12
12
  attribute :monospace, ::Sts::NisoSts::Monospace, collection: true
13
13
  attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
14
14
  attribute :xref, ::Sts::TbxIsoTml::Xref, collection: true
15
+ attribute :sub, ::Sts::NisoSts::Sub, collection: true
16
+ attribute :sup, ::Sts::NisoSts::Sup, collection: true
17
+ attribute :sc, ::Sts::NisoSts::Sc, collection: true
18
+ attribute :std, ::Sts::NisoSts::ReferenceStandard, collection: true
19
+ attribute :ext_link, ::Sts::NisoSts::ExtLink, collection: true
20
+ attribute :inline_formula, ::Sts::NisoSts::InlineFormula, collection: true
21
+ attribute :break, ::Sts::NisoSts::Break, collection: true
15
22
 
16
23
  xml do
17
24
  element "sup"
@@ -26,6 +33,13 @@ module Sts
26
33
  map_element "monospace", to: :monospace
27
34
  map_element "styled-content", to: :styled_content
28
35
  map_element "xref", to: :xref
36
+ map_element "sub", to: :sub
37
+ map_element "sup", to: :sup
38
+ map_element "sc", to: :sc
39
+ map_element "std", to: :std
40
+ map_element "ext-link", to: :ext_link
41
+ map_element "inline-formula", to: :inline_formula
42
+ map_element "break", to: :break
29
43
  end
30
44
  end
31
45
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Metrics/BlockLength
3
+ # rubocop:disable-next Metrics/BlockLength
4
4
  module Sts
5
5
  module NisoSts
6
6
  class Term < Lutaml::Model::Serializable
@@ -20,6 +20,13 @@ module Sts
20
20
  attribute :std, ::Sts::NisoSts::ReferenceStandard, collection: true
21
21
  attribute :ext_link, ::Sts::NisoSts::ExtLink
22
22
  attribute :entailed_term, ::Sts::TbxIsoTml::EntailedTerm
23
+ attribute :sub, ::Sts::NisoSts::Sub, collection: true
24
+ attribute :sup, ::Sts::NisoSts::Sup, collection: true
25
+ attribute :sc, ::Sts::NisoSts::Sc, collection: true
26
+ attribute :monospace, ::Sts::NisoSts::Monospace, collection: true
27
+ attribute :underline, ::Sts::NisoSts::Underline, collection: true
28
+ attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
29
+ attribute :break, ::Sts::NisoSts::Break, collection: true
23
30
  attribute :specific_use, :string,
24
31
  values: ["abbreviation", "acronym", "equation", "formula", "fullForm", "symbol", "variant"]
25
32
  attribute :term_status, :string,
@@ -63,8 +70,14 @@ module Sts
63
70
  map_element "uri", to: :uri
64
71
  map_element "std", to: :std
65
72
  map_element "xref", to: :xref
73
+ map_element "sub", to: :sub
74
+ map_element "sup", to: :sup
75
+ map_element "sc", to: :sc
76
+ map_element "monospace", to: :monospace
77
+ map_element "underline", to: :underline
78
+ map_element "styled-content", to: :styled_content
79
+ map_element "break", to: :break
66
80
  end
67
81
  end
68
82
  end
69
83
  end
70
- # rubocop:enable Metrics/BlockLength
@@ -18,6 +18,7 @@ module Sts
18
18
  attribute :styled_content, Sts::NisoSts::StyledContent, collection: true
19
19
  attribute :monospace, Sts::NisoSts::Monospace, collection: true
20
20
  attribute :sc, Sts::NisoSts::Sc, collection: true
21
+ attribute :ext_link, Sts::NisoSts::ExtLink, collection: true
21
22
 
22
23
  xml do
23
24
  element "title"
@@ -38,6 +39,7 @@ module Sts
38
39
  map_element "styled-content", to: :styled_content
39
40
  map_element "monospace", to: :monospace
40
41
  map_element "sc", to: :sc
42
+ map_element "ext-link", to: :ext_link
41
43
  end
42
44
  end
43
45
  end
@@ -4,9 +4,14 @@ module Sts
4
4
  module Profiles
5
5
  module IsoIec
6
6
  module Constraints
7
+ # Annex F.2 of the Guidelines rules ids out on several elements a wider
8
+ # list would sweep in: "No ids or other attributes used for <p>", "No id
9
+ # attribute in any <list> or <list-item>", "No id attribute in
10
+ # <non-normative-note>". The elements below are the ones both Annex F
11
+ # and the reference documents in this repository consistently carry an
12
+ # id on.
7
13
  REQUIRED_ID_ELEMENTS = %w[
8
- sec app fig table-wrap disp-formula ref-list ref p term-sec
9
- graphic boxed-text list def-list non-normative-note
14
+ sec app fig table-wrap disp-formula term-sec ref
10
15
  ].freeze
11
16
 
12
17
  REQUIRED_FRONT_CHILDREN = %w[
@@ -21,15 +26,13 @@ module Sts
21
26
  originator doc-type doc-number
22
27
  ].freeze
23
28
 
24
- ID_PATTERNS = {
25
- "sec" => /\Asec_\d+(\.\d+)*\z/,
26
- "app" => /\A(app|annex)_[A-Z]\z/,
27
- "fig" => /\Afig_[A-Z\d]+\z/,
28
- "table-wrap" => /\Atab_[A-Z\d]+\z/,
29
- "disp-formula" => /\Afor_[A-Z\d]+\z/,
30
- "ref" => /\Aref_\d+\z/,
31
- "term-sec" => /\Aterm_\d+(\.\d+)*\z/,
32
- "p" => /\Ap_[\w.]+\z/,
29
+ # <comm-ref> spells out the organization at ISO but not at IEC. These
30
+ # are the literal examples given in the Guidelines, not patterns -- no
31
+ # document in this repository carries a non-empty <comm-ref>, so there
32
+ # is nothing to validate a pattern against.
33
+ COMM_REF_EXAMPLES = {
34
+ "ISO" => "ISO/TC 126/SC 1",
35
+ "IEC" => "TC 25",
33
36
  }.freeze
34
37
 
35
38
  STD_ID_TYPES = %w[dated undated isbn doi].freeze
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sts
4
+ module Profiles
5
+ module IsoIec
6
+ # One of the semantic ID schemes tabulated in Annex F of the NISO STS 1.2
7
+ # IEC/ISO Coding Guidelines (ed. 2.1).
8
+ #
9
+ # Annex F warns that "IDs generated in OSD are arbitrary" and that it is
10
+ # "not recommended to base any exploitation of ISO or IEC XML on semantic
11
+ # IDs". Scheme checking is therefore opt-in, never a default.
12
+ class IdScheme
13
+ # Element name => documented id prefix. Restricted to the elements both
14
+ # Annex F.1 (IEC) and Annex F.2 (ISO) tabulate.
15
+ SCHEMES = {
16
+ iso: {
17
+ "sec" => "sec_",
18
+ "term-sec" => "sec_",
19
+ "fig" => "fig_",
20
+ "table-wrap" => "tab_",
21
+ "disp-formula" => "formula_",
22
+ }.freeze,
23
+ iec: {
24
+ "sec" => "sec-",
25
+ "term-sec" => "con-",
26
+ "fig" => "fig-",
27
+ "table-wrap" => "tab-",
28
+ "disp-formula" => "for-",
29
+ }.freeze,
30
+ }.freeze
31
+
32
+ # Element name => [prefix, matcher], built once at load. Interpolating
33
+ # the matcher per call instead is 18x slower, and a document can carry
34
+ # thousands of ids.
35
+ #
36
+ # ISO/CS prefixes ids with a document identifier, e.g.
37
+ # iso_10993-1_2009_en_fig_1, so the prefix may follow a separator.
38
+ MATCHERS = SCHEMES.transform_values do |prefixes|
39
+ prefixes.to_h do |element, prefix|
40
+ [element, [prefix, /(?:\A|[_-])#{Regexp.escape(prefix)}/].freeze]
41
+ end.freeze
42
+ end.freeze
43
+
44
+ def initialize(name)
45
+ @name = name
46
+ @matchers = MATCHERS.fetch(name) do
47
+ raise ArgumentError, "unknown ISO/IEC id scheme #{name.inspect}"
48
+ end
49
+ end
50
+
51
+ # Returns a message describing how +id+ departs from this scheme, or
52
+ # nil when it conforms. Elements the scheme does not cover are not
53
+ # checked.
54
+ def violation(element, id)
55
+ prefix, matcher = @matchers[element]
56
+ return if prefix.nil? || id.match?(matcher)
57
+
58
+ "<#{element}> id '#{id}' does not follow the #{@name} ID scheme " \
59
+ "(expected prefix '#{prefix}')"
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -4,15 +4,40 @@ module Sts
4
4
  module Profiles
5
5
  module IsoIec
6
6
  class Validator
7
+ # Pass +id_scheme+ (+:iso+ or +:iec+) to check ids against one of the
8
+ # semantic ID schemes in Annex F of the Coding Guidelines. Left out,
9
+ # ids are not checked -- the Guidelines call OSD ids arbitrary.
10
+ def initialize(id_scheme: nil)
11
+ @id_scheme = id_scheme.nil? ? nil : IdScheme.new(id_scheme)
12
+ end
13
+
7
14
  def validate(document)
8
15
  errors = []
9
16
  errors.concat(validate_structure(document))
10
17
  errors.concat(validate_metadata(document))
18
+ errors.concat(validate_ids(document))
11
19
  errors
12
20
  end
13
21
 
14
22
  private
15
23
 
24
+ def validate_ids(doc)
25
+ return [] unless @id_scheme
26
+
27
+ element_ids(doc).filter_map do |element, id|
28
+ @id_scheme.violation(element, id)
29
+ end
30
+ end
31
+
32
+ # Every id in the document, as [element name, id] pairs. Reading them
33
+ # back off the serialized document covers the whole tree, which walking
34
+ # the model's accessors by hand would not.
35
+ def element_ids(doc)
36
+ Moxml.new.parse(doc.to_xml).xpath("//*[@id]").map do |node|
37
+ [node.name, node["id"]]
38
+ end
39
+ end
40
+
16
41
  def validate_structure(doc)
17
42
  errors = []
18
43
  errors << "ISO/IEC profile requires <front>" unless doc.front
@@ -4,6 +4,7 @@ module Sts
4
4
  module Profiles
5
5
  module IsoIec
6
6
  autoload :Constraints, "#{__dir__}/iso_iec/constraints"
7
+ autoload :IdScheme, "#{__dir__}/iso_iec/id_scheme"
7
8
  autoload :Validator, "#{__dir__}/iso_iec/validator"
8
9
  end
9
10
  end
data/lib/sts/profiles.rb CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  module Sts
4
4
  module Profiles
5
+ # Raised when a usage profile is requested by a name this gem does not know.
6
+ class UnknownProfileError < StandardError; end
7
+
5
8
  autoload :IsoIec, "#{__dir__}/profiles/iso_iec"
9
+
10
+ # Returns the validator for a usage profile.
11
+ #
12
+ # A profile is a constraint layer over an already-parsed document, so
13
+ # parsing is unaffected -- parse first, then validate:
14
+ #
15
+ # doc = Sts::NisoSts::Standard.from_xml(xml)
16
+ # Sts::Profiles.validator(:iso_iec).validate(doc)
17
+ #
18
+ # Pass +id_scheme+ to additionally check ids against one of the semantic
19
+ # ID schemes in Annex F of the IEC/ISO Coding Guidelines:
20
+ #
21
+ # Sts::Profiles.validator(:iso_iec, id_scheme: :iso).validate(doc)
22
+ #
23
+ # Only +:iso_iec+ is currently available. An unknown +name+ raises
24
+ # UnknownProfileError; an unknown +id_scheme+ raises ArgumentError.
25
+ def self.validator(name, id_scheme: nil)
26
+ unless name == :iso_iec
27
+ raise UnknownProfileError, "unknown usage profile #{name.inspect}"
28
+ end
29
+
30
+ IsoIec::Validator.new(id_scheme: id_scheme)
31
+ end
6
32
  end
7
33
  end
@@ -18,6 +18,9 @@ module Sts
18
18
  attribute :fn, ::Sts::NisoSts::Fn, collection: true
19
19
  attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
20
20
  attribute :bold, ::Sts::TbxIsoTml::Bold, collection: true
21
+ attribute :std, ::Sts::NisoSts::ReferenceStandard, collection: true
22
+ attribute :inline_formula, ::Sts::NisoSts::InlineFormula, collection: true
23
+ attribute :break, ::Sts::NisoSts::Break, collection: true
21
24
 
22
25
  xml do
23
26
  element "bold"
@@ -38,6 +41,9 @@ module Sts
38
41
  map_element "fn", to: :fn
39
42
  map_element "styled-content", to: :styled_content
40
43
  map_element "bold", to: :bold
44
+ map_element "std", to: :std
45
+ map_element "inline-formula", to: :inline_formula
46
+ map_element "break", to: :break
41
47
  end
42
48
  end
43
49
  end
@@ -19,6 +19,8 @@ module Sts
19
19
  attribute :monospace, ::Sts::NisoSts::Monospace, collection: true
20
20
  attribute :ext_link, ::Sts::NisoSts::ExtLink, collection: true
21
21
  attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
22
+ attribute :sc, ::Sts::NisoSts::Sc, collection: true
23
+ attribute :break, ::Sts::NisoSts::Break, collection: true
22
24
 
23
25
  xml do
24
26
  element "definition"
@@ -41,6 +43,8 @@ module Sts
41
43
  map_element "monospace", to: :monospace
42
44
  map_element "ext-link", to: :ext_link
43
45
  map_element "styled-content", to: :styled_content
46
+ map_element "sc", to: :sc
47
+ map_element "break", to: :break
44
48
  end
45
49
  end
46
50
  end
@@ -11,6 +11,13 @@ module Sts
11
11
  attribute :std, ::Sts::NisoSts::ReferenceStandard, collection: true
12
12
  attribute :italic, ::Sts::TbxIsoTml::Italic, collection: true
13
13
  attribute :bold, ::Sts::TbxIsoTml::Bold, collection: true
14
+ attribute :sub, ::Sts::NisoSts::Sub, collection: true
15
+ attribute :sup, ::Sts::NisoSts::Sup, collection: true
16
+ attribute :monospace, ::Sts::NisoSts::Monospace, collection: true
17
+ attribute :sc, ::Sts::NisoSts::Sc, collection: true
18
+ attribute :ext_link, ::Sts::NisoSts::ExtLink, collection: true
19
+ attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
20
+ attribute :break, ::Sts::NisoSts::Break, collection: true
14
21
 
15
22
  xml do
16
23
  element "example"
@@ -27,6 +34,13 @@ module Sts
27
34
  map_element "std", to: :std
28
35
  map_element "italic", to: :italic
29
36
  map_element "bold", to: :bold
37
+ map_element "sub", to: :sub
38
+ map_element "sup", to: :sup
39
+ map_element "monospace", to: :monospace
40
+ map_element "sc", to: :sc
41
+ map_element "ext-link", to: :ext_link
42
+ map_element "styled-content", to: :styled_content
43
+ map_element "break", to: :break
30
44
  end
31
45
  end
32
46
  end
@@ -18,6 +18,9 @@ module Sts
18
18
  attribute :fn, ::Sts::NisoSts::Fn, collection: true
19
19
  attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
20
20
  attribute :italic, ::Sts::TbxIsoTml::Italic, collection: true
21
+ attribute :std, ::Sts::NisoSts::ReferenceStandard, collection: true
22
+ attribute :inline_formula, ::Sts::NisoSts::InlineFormula, collection: true
23
+ attribute :break, ::Sts::NisoSts::Break, collection: true
21
24
 
22
25
  xml do
23
26
  element "italic"
@@ -38,6 +41,9 @@ module Sts
38
41
  map_element "fn", to: :fn
39
42
  map_element "styled-content", to: :styled_content
40
43
  map_element "italic", to: :italic
44
+ map_element "std", to: :std
45
+ map_element "inline-formula", to: :inline_formula
46
+ map_element "break", to: :break
41
47
  end
42
48
  end
43
49
  end
@@ -16,6 +16,11 @@ module Sts
16
16
  attribute :italic, ::Sts::TbxIsoTml::Italic, collection: true
17
17
  attribute :bold, ::Sts::TbxIsoTml::Bold, collection: true
18
18
  attribute :inline_formula, ::Sts::NisoSts::InlineFormula, collection: true
19
+ attribute :monospace, ::Sts::NisoSts::Monospace, collection: true
20
+ attribute :sc, ::Sts::NisoSts::Sc, collection: true
21
+ attribute :ext_link, ::Sts::NisoSts::ExtLink, collection: true
22
+ attribute :styled_content, ::Sts::NisoSts::StyledContent, collection: true
23
+ attribute :break, ::Sts::NisoSts::Break, collection: true
19
24
 
20
25
  xml do
21
26
  element "note"
@@ -35,6 +40,11 @@ module Sts
35
40
  map_element "xref", to: :xref
36
41
  map_element "math", to: :math
37
42
  map_element "inline-formula", to: :inline_formula
43
+ map_element "monospace", to: :monospace
44
+ map_element "sc", to: :sc
45
+ map_element "ext-link", to: :ext_link
46
+ map_element "styled-content", to: :styled_content
47
+ map_element "break", to: :break
38
48
  end
39
49
  end
40
50
  end
data/lib/sts/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sts
4
- VERSION = "0.6.11"
4
+ VERSION = "0.6.12"
5
5
  end
data/lib/sts.rb CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  require "lutaml/model"
4
4
  require "mml"
5
+ # The ISO/IEC profile validator reads ids back off a serialized document.
6
+ # lutaml-model already pulls Moxml in, but naming a constant we only get
7
+ # transitively is how a dependency bump breaks us later.
8
+ require "moxml"
5
9
 
6
10
  module Sts
7
11
  autoload :IsoSts, "#{__dir__}/sts/iso_sts"