relaton-un 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7e304e91ea7764c40ca5b60e3de858573613e0217e39c5be3e4149e5393cd281
4
+ data.tar.gz: ea0d6d320d84205e1656ec73ac9ea80af87eefe0e73e20ca75be2594cc980a63
5
+ SHA512:
6
+ metadata.gz: 5b5ebfd78740dd9c8caf58a5edb290a44216e63ea5d35e8a3c32c2ecc63f8b30a37265c33adeb809c196b66bff009cc4773657b98353c4b935ccadbd83e46fec
7
+ data.tar.gz: f952eaf7cf7de2c6c1a420148a23c7c569f38fdac0828f6cac98e86df9f5a2f61f708a54c1b36943e2f3a1b08ac400c38dc5e474e3f0a72246a7de66caec9d66
@@ -0,0 +1,32 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: macos
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-macos:
13
+ name: Test on Ruby ${{ matrix.ruby }} macOS
14
+ runs-on: macos-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ - name: Use Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ architecture: 'x64'
26
+ - name: Update gems
27
+ run: |
28
+ sudo gem install bundler --force
29
+ bundle install --jobs 4 --retry 3
30
+ - name: Run specs
31
+ run: |
32
+ bundle exec rake
@@ -0,0 +1,32 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: ubuntu
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-linux:
13
+ name: Test on Ruby ${{ matrix.ruby }} Ubuntu
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ - name: Use Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ architecture: 'x64'
26
+ - name: Update gems
27
+ run: |
28
+ gem install bundler
29
+ bundle install --jobs 4 --retry 3
30
+ - name: Run specs
31
+ run: |
32
+ bundle exec rake
@@ -0,0 +1,35 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: windows
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-windows:
13
+ name: Test on Ruby ${{ matrix.ruby }} Windows
14
+ runs-on: windows-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ - name: Use Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ architecture: 'x64'
26
+ - name: Update gems
27
+ shell: pwsh
28
+ run: |
29
+ gem install bundler
30
+ bundle config --local path vendor/bundle
31
+ bundle update
32
+ bundle install --jobs 4 --retry 3
33
+ - name: Run specs
34
+ run: |
35
+ bundle exec rake
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.pryrc
10
+ /.rubocop-https*
11
+
12
+ .rspec_status
13
+ .vscode/
14
+ .byebug_history
15
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ # This project follows the Ribose OSS style guide.
2
+ # https://github.com/riboseinc/oss-guides
3
+ # All project-specific additions and overrides should be specified in this file.
4
+
5
+ inherit_from:
6
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
+ AllCops:
8
+ TargetRubyVersion: 2.3
9
+ Rails:
10
+ Enabled: true
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in relaton-un.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Andrei Kislichenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,115 @@
1
+ = Relaton for UN documents
2
+
3
+ RelatonCalconnect is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
4
+
5
+ You can use it to retrieve metadata of Calconnect Standards from https://standards.calconnect.org, and access such metadata through the `CcBibliographicItem` object.
6
+
7
+ == Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ [source,ruby]
12
+ ----
13
+ gem 'relaton-un'
14
+ ----
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install relaton-un
23
+
24
+ == Usage
25
+
26
+ === Search for a standard using keywords
27
+
28
+ [source]
29
+ ----
30
+ require 'relaton_un'
31
+
32
+ hits = RelatonUn::UnBibliography.search("TRADE/CEFACT/2004/32")
33
+ => <RelatonUn::HitCollection:0x007fc4e6ec2018 @ref=TRADE/CEFACT/2004/32 @fetched=false>
34
+
35
+ item = hits[0].fetch
36
+ => #<RelatonUn::UnBibliographicItem:0x007fc4e6ac3138
37
+ ...
38
+ ----
39
+
40
+ === XML serialization
41
+
42
+ [source]
43
+ ----
44
+ item.to_xml
45
+ => '<bibitem id="TRADE/CEFACT/2004/32">
46
+ <title type="main" format="text/plain" language="en" script="Latn">SECRETARIAT REVIEW OF UN/LOCODE, 19 DECEMBER 2003 / SUBMITTED BY THE SECRETARIAT</title>
47
+ <uri type="pdf">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement</uri>
48
+ <uri type="word">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/doc/G0430683.DOC?OpenElement</uri>
49
+ <docidentifier type="UN">TRADE/CEFACT/2004/32</docidentifier>
50
+ <docnumber>TRADE/CEFACT/2004/32</docnumber>
51
+ ...
52
+ </bibitem>'
53
+ ----
54
+ With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and adds flavour `ext` element.
55
+ [source]
56
+ ----
57
+ item.to_xml bibdata: true
58
+ => '<bibdata type="standard">
59
+ <fetched>2020-03-13</fetched>
60
+ <title type="main" format="text/plain" language="en" script="Latn">SECRETARIAT REVIEW OF UN/LOCODE, 19 DECEMBER 2003 / SUBMITTED BY THE SECRETARIAT</title>
61
+ <uri type="pdf">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/pdf/G0430683.pdf?OpenElement</uri>
62
+ <uri type="word">https://documents-dds-ny.un.org/doc/UNDOC/GEN/G04/306/83/doc/G0430683.DOC?OpenElement</uri>
63
+ <docidentifier type="UN">TRADE/CEFACT/2004/32</docidentifier>
64
+ <docnumber>TRADE/CEFACT/2004/32</docnumber>
65
+ ...
66
+ </bibdata>'
67
+ ----
68
+
69
+ === Get code, and year
70
+ [source]
71
+ ----
72
+ RelatonUn::UnBibliography.get "UN TRADE/CEFACT/2004/32"
73
+ [relaton-un] ("UN TRADE/CEFACT/2004/32") fetching...
74
+ [relaton-un] ("UN TRADE/CEFACT/2004/32") found TRADE/CEFACT/2004/32
75
+ => #<RelatonUn::UnBibliographicItem:0x007fdc5f1c3a20
76
+ ...
77
+ ----
78
+
79
+ === Create bibliographic item from XML
80
+ [source]
81
+ ----
82
+ RelatonUn::XMLParser.from_xml File.read('spec/fixtures/un_bib.xml')
83
+ => #<RelatonUn::UnBibliographicItem:0x007fdc5e7ab678
84
+ ...
85
+ ----
86
+
87
+ === Create bibliographic item from YAML
88
+ [source]
89
+ ----
90
+ hash = YAML.load_file 'spec/fixtures/un_bib.yaml'
91
+ => {"id"=>"TRADE/CEFACT/2004/32",
92
+ ...
93
+
94
+ bib_hash = RelatonUn::HashConverter.hash_to_bib hash
95
+ => {:id=>"TRADE/CEFACT/2004/32",
96
+ ...
97
+
98
+ RelatonUn::UnBibliographicItem.new bib_hash
99
+ => #<RelatonUn::UnBibliographicItem:0x007fdc5e061908
100
+ ...
101
+ ----
102
+
103
+ == Development
104
+
105
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
106
+
107
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
108
+
109
+ == Contributing
110
+
111
+ Bug reports and pull requests are welcome on GitHub at https://github.com/calconnect/relaton_un.
112
+
113
+ == License
114
+
115
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "relaton_un"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,986 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <include href="biblio.rng"/>
4
+ <start>
5
+ <ref name="document"/>
6
+ </start>
7
+ <define name="document">
8
+ <element name="document">
9
+ <optional>
10
+ <attribute name="identifier"/>
11
+ </optional>
12
+ <ref name="bibdata"/>
13
+ <ref name="sections"/>
14
+ <zeroOrMore>
15
+ <ref name="references"/>
16
+ </zeroOrMore>
17
+ </element>
18
+ </define>
19
+ <define name="bibdata">
20
+ <element name="bibdata">
21
+ <ref name="BibData"/>
22
+ </element>
23
+ </define>
24
+ <define name="sections">
25
+ <element name="sections">
26
+ <oneOrMore>
27
+ <ref name="section"/>
28
+ </oneOrMore>
29
+ </element>
30
+ </define>
31
+ <define name="section">
32
+ <element name="section">
33
+ <ref name="Basic-Section"/>
34
+ <zeroOrMore>
35
+ <ref name="section"/>
36
+ </zeroOrMore>
37
+ </element>
38
+ </define>
39
+ <define name="Basic-Section">
40
+ <optional>
41
+ <attribute name="id">
42
+ <data type="ID"/>
43
+ </attribute>
44
+ </optional>
45
+ <optional>
46
+ <ref name="section-title"/>
47
+ </optional>
48
+ <optional>
49
+ <ref name="BasicBlock"/>
50
+ </optional>
51
+ <zeroOrMore>
52
+ <ref name="note"/>
53
+ </zeroOrMore>
54
+ </define>
55
+ <define name="references">
56
+ <element name="references">
57
+ <optional>
58
+ <attribute name="id">
59
+ <data type="ID"/>
60
+ </attribute>
61
+ </optional>
62
+ <optional>
63
+ <ref name="section-title"/>
64
+ </optional>
65
+ <zeroOrMore>
66
+ <ref name="BasicBlock"/>
67
+ </zeroOrMore>
68
+ <zeroOrMore>
69
+ <ref name="bibitem"/>
70
+ </zeroOrMore>
71
+ </element>
72
+ </define>
73
+ <define name="section-title">
74
+ <element name="title">
75
+ <zeroOrMore>
76
+ <ref name="TextElement"/>
77
+ </zeroOrMore>
78
+ </element>
79
+ </define>
80
+ <define name="BasicBlock">
81
+ <choice>
82
+ <ref name="paragraph-with-footnote"/>
83
+ <ref name="table"/>
84
+ <ref name="formula"/>
85
+ <ref name="admonition"/>
86
+ <ref name="ol"/>
87
+ <ref name="ul"/>
88
+ <ref name="dl"/>
89
+ <ref name="figure"/>
90
+ <ref name="quote"/>
91
+ <ref name="sourcecode"/>
92
+ <ref name="example"/>
93
+ <ref name="review"/>
94
+ <ref name="pre"/>
95
+ </choice>
96
+ </define>
97
+ <define name="paragraph">
98
+ <element name="p">
99
+ <ref name="ParagraphType"/>
100
+ </element>
101
+ </define>
102
+ <define name="Alignments">
103
+ <choice>
104
+ <value>left</value>
105
+ <value>right</value>
106
+ <value>center</value>
107
+ <value>justified</value>
108
+ </choice>
109
+ </define>
110
+ <define name="ParagraphType">
111
+ <attribute name="id">
112
+ <data type="ID"/>
113
+ </attribute>
114
+ <optional>
115
+ <attribute name="align">
116
+ <ref name="Alignments"/>
117
+ </attribute>
118
+ </optional>
119
+ <zeroOrMore>
120
+ <ref name="TextElement"/>
121
+ </zeroOrMore>
122
+ <zeroOrMore>
123
+ <ref name="note"/>
124
+ </zeroOrMore>
125
+ </define>
126
+ <define name="paragraph-with-footnote">
127
+ <element name="p">
128
+ <attribute name="id">
129
+ <data type="ID"/>
130
+ </attribute>
131
+ <optional>
132
+ <attribute name="align">
133
+ <ref name="Alignments"/>
134
+ </attribute>
135
+ </optional>
136
+ <zeroOrMore>
137
+ <choice>
138
+ <ref name="TextElement"/>
139
+ <ref name="fn"/>
140
+ </choice>
141
+ </zeroOrMore>
142
+ <zeroOrMore>
143
+ <ref name="note"/>
144
+ </zeroOrMore>
145
+ </element>
146
+ </define>
147
+ <define name="note">
148
+ <element name="note">
149
+ <attribute name="id">
150
+ <data type="ID"/>
151
+ </attribute>
152
+ <oneOrMore>
153
+ <ref name="paragraph"/>
154
+ </oneOrMore>
155
+ </element>
156
+ </define>
157
+ <define name="review">
158
+ <element name="review">
159
+ <attribute name="id">
160
+ <data type="ID"/>
161
+ </attribute>
162
+ <attribute name="reviewer"/>
163
+ <optional>
164
+ <attribute name="date">
165
+ <data type="dateTime"/>
166
+ </attribute>
167
+ </optional>
168
+ <attribute name="from">
169
+ <data type="IDREF"/>
170
+ </attribute>
171
+ <optional>
172
+ <attribute name="to">
173
+ <data type="IDREF"/>
174
+ </attribute>
175
+ </optional>
176
+ <oneOrMore>
177
+ <ref name="paragraph"/>
178
+ </oneOrMore>
179
+ </element>
180
+ </define>
181
+ <define name="formula">
182
+ <element name="formula">
183
+ <attribute name="id">
184
+ <data type="ID"/>
185
+ </attribute>
186
+ <optional>
187
+ <attribute name="unnumbered">
188
+ <data type="boolean"/>
189
+ </attribute>
190
+ </optional>
191
+ <ref name="stem"/>
192
+ <optional>
193
+ <ref name="dl"/>
194
+ </optional>
195
+ <zeroOrMore>
196
+ <ref name="note"/>
197
+ </zeroOrMore>
198
+ </element>
199
+ </define>
200
+ <define name="quote">
201
+ <element name="quote">
202
+ <attribute name="id">
203
+ <data type="ID"/>
204
+ </attribute>
205
+ <optional>
206
+ <attribute name="alignment">
207
+ <ref name="Alignments"/>
208
+ </attribute>
209
+ </optional>
210
+ <optional>
211
+ <ref name="quote-source"/>
212
+ </optional>
213
+ <optional>
214
+ <ref name="quote-author"/>
215
+ </optional>
216
+ <oneOrMore>
217
+ <ref name="paragraph-with-footnote"/>
218
+ </oneOrMore>
219
+ <zeroOrMore>
220
+ <ref name="note"/>
221
+ </zeroOrMore>
222
+ </element>
223
+ </define>
224
+ <define name="quote-source">
225
+ <element name="source">
226
+ <ref name="erefType"/>
227
+ </element>
228
+ </define>
229
+ <define name="quote-author">
230
+ <element name="author">
231
+ <text/>
232
+ </element>
233
+ </define>
234
+ <define name="sourcecode">
235
+ <element name="sourcecode">
236
+ <attribute name="id">
237
+ <data type="ID"/>
238
+ </attribute>
239
+ <optional>
240
+ <attribute name="unnumbered">
241
+ <data type="boolean"/>
242
+ </attribute>
243
+ </optional>
244
+ <optional>
245
+ <attribute name="lang"/>
246
+ </optional>
247
+ <optional>
248
+ <ref name="tname"/>
249
+ </optional>
250
+ <oneOrMore>
251
+ <choice>
252
+ <text/>
253
+ <ref name="callout"/>
254
+ </choice>
255
+ </oneOrMore>
256
+ <zeroOrMore>
257
+ <ref name="annotation"/>
258
+ </zeroOrMore>
259
+ <zeroOrMore>
260
+ <ref name="note"/>
261
+ </zeroOrMore>
262
+ </element>
263
+ </define>
264
+ <define name="pre">
265
+ <element name="pre">
266
+ <attribute name="id">
267
+ <data type="ID"/>
268
+ </attribute>
269
+ <optional>
270
+ <ref name="tname"/>
271
+ </optional>
272
+ <text/>
273
+ <zeroOrMore>
274
+ <ref name="note"/>
275
+ </zeroOrMore>
276
+ </element>
277
+ </define>
278
+ <define name="table">
279
+ <element name="table">
280
+ <attribute name="id">
281
+ <data type="ID"/>
282
+ </attribute>
283
+ <optional>
284
+ <attribute name="unnumbered">
285
+ <data type="boolean"/>
286
+ </attribute>
287
+ </optional>
288
+ <optional>
289
+ <attribute name="alt"/>
290
+ </optional>
291
+ <optional>
292
+ <attribute name="uri">
293
+ <data type="anyURI"/>
294
+ </attribute>
295
+ </optional>
296
+ <optional>
297
+ <ref name="tname"/>
298
+ </optional>
299
+ <optional>
300
+ <ref name="thead"/>
301
+ </optional>
302
+ <ref name="tbody"/>
303
+ <optional>
304
+ <ref name="tfoot"/>
305
+ </optional>
306
+ <zeroOrMore>
307
+ <ref name="table-note"/>
308
+ </zeroOrMore>
309
+ <optional>
310
+ <ref name="dl"/>
311
+ </optional>
312
+ </element>
313
+ </define>
314
+ <define name="tname">
315
+ <element name="name">
316
+ <text/>
317
+ </element>
318
+ </define>
319
+ <define name="tclass">
320
+ <element name="name">
321
+ <text/>
322
+ </element>
323
+ </define>
324
+ <define name="thead">
325
+ <element name="thead">
326
+ <ref name="tr"/>
327
+ </element>
328
+ </define>
329
+ <define name="tfoot">
330
+ <element name="tfoot">
331
+ <ref name="tr"/>
332
+ </element>
333
+ </define>
334
+ <define name="tbody">
335
+ <element name="tbody">
336
+ <oneOrMore>
337
+ <ref name="tr"/>
338
+ </oneOrMore>
339
+ </element>
340
+ </define>
341
+ <define name="table-note">
342
+ <element name="note">
343
+ <ref name="paragraph"/>
344
+ </element>
345
+ </define>
346
+ <define name="tr">
347
+ <element name="tr">
348
+ <oneOrMore>
349
+ <choice>
350
+ <ref name="td"/>
351
+ <ref name="th"/>
352
+ </choice>
353
+ </oneOrMore>
354
+ </element>
355
+ </define>
356
+ <define name="td">
357
+ <element name="td">
358
+ <optional>
359
+ <attribute name="colspan"/>
360
+ </optional>
361
+ <optional>
362
+ <attribute name="rowspan"/>
363
+ </optional>
364
+ <optional>
365
+ <attribute name="align">
366
+ <choice>
367
+ <value>left</value>
368
+ <value>right</value>
369
+ <value>center</value>
370
+ </choice>
371
+ </attribute>
372
+ </optional>
373
+ <choice>
374
+ <zeroOrMore>
375
+ <ref name="TextElement"/>
376
+ </zeroOrMore>
377
+ <oneOrMore>
378
+ <ref name="paragraph-with-footnote"/>
379
+ </oneOrMore>
380
+ </choice>
381
+ </element>
382
+ </define>
383
+ <define name="th">
384
+ <element name="th">
385
+ <optional>
386
+ <attribute name="colspan"/>
387
+ </optional>
388
+ <optional>
389
+ <attribute name="rowspan"/>
390
+ </optional>
391
+ <optional>
392
+ <attribute name="align">
393
+ <choice>
394
+ <value>left</value>
395
+ <value>right</value>
396
+ <value>center</value>
397
+ </choice>
398
+ </attribute>
399
+ </optional>
400
+ <choice>
401
+ <zeroOrMore>
402
+ <ref name="TextElement"/>
403
+ </zeroOrMore>
404
+ <oneOrMore>
405
+ <ref name="paragraph-with-footnote"/>
406
+ </oneOrMore>
407
+ </choice>
408
+ </element>
409
+ </define>
410
+ <define name="example">
411
+ <element name="example">
412
+ <attribute name="id">
413
+ <data type="ID"/>
414
+ </attribute>
415
+ <optional>
416
+ <attribute name="unnumbered">
417
+ <data type="boolean"/>
418
+ </attribute>
419
+ </optional>
420
+ <oneOrMore>
421
+ <choice>
422
+ <ref name="formula"/>
423
+ <ref name="ul"/>
424
+ <ref name="ol"/>
425
+ <ref name="dl"/>
426
+ <ref name="quote"/>
427
+ <ref name="sourcecode"/>
428
+ <ref name="paragraph-with-footnote"/>
429
+ </choice>
430
+ </oneOrMore>
431
+ <zeroOrMore>
432
+ <ref name="note"/>
433
+ </zeroOrMore>
434
+ </element>
435
+ </define>
436
+ <define name="admonition">
437
+ <element name="admonition">
438
+ <attribute name="type">
439
+ <ref name="AdmonitionType"/>
440
+ </attribute>
441
+ <optional>
442
+ <attribute name="class"/>
443
+ </optional>
444
+ <attribute name="id">
445
+ <data type="ID"/>
446
+ </attribute>
447
+ <optional>
448
+ <attribute name="uri">
449
+ <data type="anyURI"/>
450
+ </attribute>
451
+ </optional>
452
+ <optional>
453
+ <ref name="tname"/>
454
+ </optional>
455
+ <zeroOrMore>
456
+ <ref name="paragraph-with-footnote"/>
457
+ </zeroOrMore>
458
+ <zeroOrMore>
459
+ <ref name="note"/>
460
+ </zeroOrMore>
461
+ </element>
462
+ </define>
463
+ <define name="AdmonitionType">
464
+ <choice>
465
+ <value>warning</value>
466
+ <value>note</value>
467
+ <value>tip</value>
468
+ <value>important</value>
469
+ <value>caution</value>
470
+ <value>statement</value>
471
+ </choice>
472
+ </define>
473
+ <define name="figure">
474
+ <element name="figure">
475
+ <attribute name="id">
476
+ <data type="ID"/>
477
+ </attribute>
478
+ <optional>
479
+ <attribute name="unnumbered">
480
+ <data type="boolean"/>
481
+ </attribute>
482
+ </optional>
483
+ <optional>
484
+ <ref name="source"/>
485
+ </optional>
486
+ <optional>
487
+ <ref name="tname"/>
488
+ </optional>
489
+ <optional>
490
+ <ref name="tclass"/>
491
+ </optional>
492
+ <choice>
493
+ <ref name="image"/>
494
+ <ref name="pre"/>
495
+ <zeroOrMore>
496
+ <ref name="figure"/>
497
+ </zeroOrMore>
498
+ </choice>
499
+ <zeroOrMore>
500
+ <ref name="fn"/>
501
+ </zeroOrMore>
502
+ <optional>
503
+ <ref name="dl"/>
504
+ </optional>
505
+ <zeroOrMore>
506
+ <ref name="note"/>
507
+ </zeroOrMore>
508
+ </element>
509
+ </define>
510
+ <define name="TextElement">
511
+ <choice>
512
+ <text/>
513
+ <ref name="em"/>
514
+ <ref name="eref"/>
515
+ <ref name="strong"/>
516
+ <ref name="stem"/>
517
+ <ref name="sub"/>
518
+ <ref name="sup"/>
519
+ <ref name="tt"/>
520
+ <ref name="underline"/>
521
+ <ref name="keyword"/>
522
+ <ref name="ruby"/>
523
+ <ref name="strike"/>
524
+ <ref name="smallcap"/>
525
+ <ref name="xref"/>
526
+ <ref name="br"/>
527
+ <ref name="hyperlink"/>
528
+ <ref name="hr"/>
529
+ <ref name="pagebreak"/>
530
+ <ref name="bookmark"/>
531
+ <ref name="image"/>
532
+ </choice>
533
+ </define>
534
+ <define name="PureTextElement">
535
+ <choice>
536
+ <text/>
537
+ <ref name="em"/>
538
+ <ref name="strong"/>
539
+ <ref name="sub"/>
540
+ <ref name="sup"/>
541
+ <ref name="tt"/>
542
+ <ref name="underline"/>
543
+ <ref name="strike"/>
544
+ <ref name="smallcap"/>
545
+ <ref name="br"/>
546
+ </choice>
547
+ </define>
548
+ <define name="source">
549
+ <element name="source">
550
+ <ref name="TypedUri"/>
551
+ </element>
552
+ </define>
553
+ <define name="em">
554
+ <element name="em">
555
+ <zeroOrMore>
556
+ <ref name="PureTextElement"/>
557
+ </zeroOrMore>
558
+ </element>
559
+ </define>
560
+ <define name="strong">
561
+ <element name="strong">
562
+ <zeroOrMore>
563
+ <ref name="PureTextElement"/>
564
+ </zeroOrMore>
565
+ </element>
566
+ </define>
567
+ <define name="tt">
568
+ <element name="tt">
569
+ <zeroOrMore>
570
+ <ref name="PureTextElement"/>
571
+ </zeroOrMore>
572
+ </element>
573
+ </define>
574
+ <define name="keyword">
575
+ <element name="keyword">
576
+ <zeroOrMore>
577
+ <ref name="PureTextElement"/>
578
+ </zeroOrMore>
579
+ </element>
580
+ </define>
581
+ <define name="sub">
582
+ <element name="sub">
583
+ <zeroOrMore>
584
+ <ref name="PureTextElement"/>
585
+ </zeroOrMore>
586
+ </element>
587
+ </define>
588
+ <define name="sup">
589
+ <element name="sup">
590
+ <zeroOrMore>
591
+ <ref name="PureTextElement"/>
592
+ </zeroOrMore>
593
+ </element>
594
+ </define>
595
+ <define name="strike">
596
+ <element name="strike">
597
+ <zeroOrMore>
598
+ <ref name="PureTextElement"/>
599
+ </zeroOrMore>
600
+ </element>
601
+ </define>
602
+ <define name="underline">
603
+ <element name="underline">
604
+ <zeroOrMore>
605
+ <ref name="PureTextElement"/>
606
+ </zeroOrMore>
607
+ </element>
608
+ </define>
609
+ <define name="smallcap">
610
+ <element name="smallcap">
611
+ <zeroOrMore>
612
+ <ref name="PureTextElement"/>
613
+ </zeroOrMore>
614
+ </element>
615
+ </define>
616
+ <define name="ruby">
617
+ <element name="ruby">
618
+ <zeroOrMore>
619
+ <choice>
620
+ <ref name="PureTextElement"/>
621
+ <ref name="rp"/>
622
+ <ref name="rt"/>
623
+ </choice>
624
+ </zeroOrMore>
625
+ </element>
626
+ </define>
627
+ <define name="rp">
628
+ <element name="rp">
629
+ <zeroOrMore>
630
+ <ref name="PureTextElement"/>
631
+ </zeroOrMore>
632
+ </element>
633
+ </define>
634
+ <define name="rt">
635
+ <element name="rt">
636
+ <zeroOrMore>
637
+ <ref name="PureTextElement"/>
638
+ </zeroOrMore>
639
+ </element>
640
+ </define>
641
+ <define name="br">
642
+ <element name="br">
643
+ <empty/>
644
+ </element>
645
+ </define>
646
+ <define name="hr">
647
+ <element name="hr">
648
+ <empty/>
649
+ </element>
650
+ </define>
651
+ <define name="pagebreak">
652
+ <element name="pagebreak">
653
+ <empty/>
654
+ </element>
655
+ </define>
656
+ <!-- bare ID element, used for referencing arbitrary spans of text -->
657
+ <define name="bookmark">
658
+ <element name="bookmark">
659
+ <attribute name="id">
660
+ <data type="ID"/>
661
+ </attribute>
662
+ <empty/>
663
+ </element>
664
+ </define>
665
+ <define name="ReferenceFormat">
666
+ <choice>
667
+ <value>external</value>
668
+ <value>inline</value>
669
+ <value>footnote</value>
670
+ <value>callout</value>
671
+ </choice>
672
+ </define>
673
+ <define name="eref">
674
+ <element name="eref">
675
+ <ref name="erefType"/>
676
+ </element>
677
+ </define>
678
+ <define name="erefType">
679
+ <optional>
680
+ <attribute name="normative">
681
+ <data type="boolean"/>
682
+ </attribute>
683
+ </optional>
684
+ <attribute name="citeas"/>
685
+ <attribute name="type">
686
+ <ref name="ReferenceFormat"/>
687
+ </attribute>
688
+ <optional>
689
+ <attribute name="alt"/>
690
+ </optional>
691
+ <ref name="CitationType"/>
692
+ <text/>
693
+ </define>
694
+ <define name="hyperlink">
695
+ <element name="link">
696
+ <attribute name="target">
697
+ <data type="anyURI"/>
698
+ </attribute>
699
+ <attribute name="type">
700
+ <ref name="ReferenceFormat"/>
701
+ </attribute>
702
+ <optional>
703
+ <attribute name="alt"/>
704
+ </optional>
705
+ <text/>
706
+ </element>
707
+ </define>
708
+ <define name="xref">
709
+ <element name="xref">
710
+ <attribute name="target">
711
+ <data type="IDREF"/>
712
+ </attribute>
713
+ <attribute name="type">
714
+ <ref name="ReferenceFormat"/>
715
+ </attribute>
716
+ <optional>
717
+ <attribute name="alt"/>
718
+ </optional>
719
+ <text/>
720
+ </element>
721
+ </define>
722
+ <define name="fn">
723
+ <element name="fn">
724
+ <attribute name="reference"/>
725
+ <oneOrMore>
726
+ <ref name="paragraph"/>
727
+ </oneOrMore>
728
+ </element>
729
+ </define>
730
+ <!--
731
+ This is xref with fixed @type="footnote", and @target built in as paragraph+
732
+ @reference replaces ReferenceElement/text
733
+ so <fn reference="2"><p>This is a footnote</p></fn>
734
+ corresponds to
735
+ <eref type="footnote" target="fn2">2</xref> <p id="fn2">This is a footnote</p>
736
+ -->
737
+ <define name="callout">
738
+ <element name="callout">
739
+ <attribute name="target">
740
+ <data type="IDREF"/>
741
+ </attribute>
742
+ <text/>
743
+ </element>
744
+ </define>
745
+ <!--
746
+ This is xref with fixed @type="callout"; the target by convention is in an annotation in the same source code snippet
747
+ so <callout target="xyz">1</callout>
748
+ corresponds to <xref type="callout" target="xyz">1</xref>
749
+ -->
750
+ <define name="image">
751
+ <element name="image">
752
+ <attribute name="id">
753
+ <data type="ID"/>
754
+ </attribute>
755
+ <attribute name="src">
756
+ <data type="anyURI"/>
757
+ </attribute>
758
+ <attribute name="mimetype"/>
759
+ <optional>
760
+ <attribute name="filename"/>
761
+ </optional>
762
+ <optional>
763
+ <attribute name="width">
764
+ <choice>
765
+ <data type="int"/>
766
+ <value>auto</value>
767
+ </choice>
768
+ </attribute>
769
+ </optional>
770
+ <optional>
771
+ <attribute name="height">
772
+ <choice>
773
+ <data type="int"/>
774
+ <value>auto</value>
775
+ </choice>
776
+ </attribute>
777
+ </optional>
778
+ <optional>
779
+ <attribute name="alt"/>
780
+ </optional>
781
+ <optional>
782
+ <attribute name="longdesc">
783
+ <data type="anyURI"/>
784
+ </attribute>
785
+ </optional>
786
+ </element>
787
+ </define>
788
+ <define name="video">
789
+ <element name="image">
790
+ <attribute name="id">
791
+ <data type="ID"/>
792
+ </attribute>
793
+ <attribute name="src">
794
+ <data type="anyURI"/>
795
+ </attribute>
796
+ <attribute name="mimetype"/>
797
+ <optional>
798
+ <attribute name="filename"/>
799
+ </optional>
800
+ <optional>
801
+ <attribute name="width">
802
+ <choice>
803
+ <data type="int"/>
804
+ <value>auto</value>
805
+ </choice>
806
+ </attribute>
807
+ </optional>
808
+ <optional>
809
+ <attribute name="height">
810
+ <choice>
811
+ <data type="int"/>
812
+ <value>auto</value>
813
+ </choice>
814
+ </attribute>
815
+ </optional>
816
+ <optional>
817
+ <attribute name="alt"/>
818
+ </optional>
819
+ <optional>
820
+ <attribute name="longdesc">
821
+ <data type="anyURI"/>
822
+ </attribute>
823
+ </optional>
824
+ <zeroOrMore>
825
+ <ref name="altsource"/>
826
+ </zeroOrMore>
827
+ </element>
828
+ </define>
829
+ <define name="audio">
830
+ <element name="image">
831
+ <attribute name="id">
832
+ <data type="ID"/>
833
+ </attribute>
834
+ <attribute name="src">
835
+ <data type="anyURI"/>
836
+ </attribute>
837
+ <attribute name="mimetype"/>
838
+ <optional>
839
+ <attribute name="filename"/>
840
+ </optional>
841
+ <optional>
842
+ <attribute name="alt"/>
843
+ </optional>
844
+ <optional>
845
+ <attribute name="longdesc">
846
+ <data type="anyURI"/>
847
+ </attribute>
848
+ </optional>
849
+ <zeroOrMore>
850
+ <ref name="altsource"/>
851
+ </zeroOrMore>
852
+ </element>
853
+ </define>
854
+ <define name="altsource">
855
+ <element name="altsource">
856
+ <attribute name="src">
857
+ <data type="anyURI"/>
858
+ </attribute>
859
+ <attribute name="mimetype"/>
860
+ <optional>
861
+ <attribute name="filename"/>
862
+ </optional>
863
+ </element>
864
+ </define>
865
+ <define name="stem">
866
+ <element name="stem">
867
+ <attribute name="type">
868
+ <choice>
869
+ <value>MathML</value>
870
+ <value>AsciiMath</value>
871
+ </choice>
872
+ </attribute>
873
+ <oneOrMore>
874
+ <choice>
875
+ <text/>
876
+ <ref name="AnyElement"/>
877
+ </choice>
878
+ </oneOrMore>
879
+ </element>
880
+ </define>
881
+ <define name="annotation">
882
+ <element name="annotation">
883
+ <attribute name="id">
884
+ <data type="ID"/>
885
+ </attribute>
886
+ <ref name="paragraph"/>
887
+ </element>
888
+ </define>
889
+ <define name="ul">
890
+ <element name="ul">
891
+ <attribute name="id">
892
+ <data type="ID"/>
893
+ </attribute>
894
+ <oneOrMore>
895
+ <ref name="li"/>
896
+ </oneOrMore>
897
+ <zeroOrMore>
898
+ <ref name="note"/>
899
+ </zeroOrMore>
900
+ </element>
901
+ </define>
902
+ <define name="li">
903
+ <element name="li">
904
+ <optional>
905
+ <attribute name="id">
906
+ <data type="ID"/>
907
+ </attribute>
908
+ </optional>
909
+ <oneOrMore>
910
+ <ref name="paragraph-with-footnote"/>
911
+ </oneOrMore>
912
+ </element>
913
+ </define>
914
+ <define name="ol">
915
+ <element name="ol">
916
+ <attribute name="id">
917
+ <data type="ID"/>
918
+ </attribute>
919
+ <attribute name="type">
920
+ <choice>
921
+ <value>roman</value>
922
+ <value>alphabet</value>
923
+ <value>arabic</value>
924
+ <value>roman_upper</value>
925
+ <value>alphabet_upper</value>
926
+ </choice>
927
+ </attribute>
928
+ <oneOrMore>
929
+ <ref name="li"/>
930
+ </oneOrMore>
931
+ <zeroOrMore>
932
+ <ref name="note"/>
933
+ </zeroOrMore>
934
+ </element>
935
+ </define>
936
+ <define name="dl">
937
+ <element name="dl">
938
+ <attribute name="id">
939
+ <data type="ID"/>
940
+ </attribute>
941
+ <oneOrMore>
942
+ <ref name="dt"/>
943
+ <ref name="dd"/>
944
+ </oneOrMore>
945
+ <zeroOrMore>
946
+ <ref name="note"/>
947
+ </zeroOrMore>
948
+ </element>
949
+ </define>
950
+ <define name="dt">
951
+ <element name="dt">
952
+ <zeroOrMore>
953
+ <ref name="TextElement"/>
954
+ </zeroOrMore>
955
+ </element>
956
+ </define>
957
+ <define name="dd">
958
+ <element name="dd">
959
+ <zeroOrMore>
960
+ <ref name="paragraph-with-footnote"/>
961
+ </zeroOrMore>
962
+ </element>
963
+ </define>
964
+ <define name="ext">
965
+ <element name="ext">
966
+ <ref name="BibDataExtensionType"/>
967
+ </element>
968
+ </define>
969
+ <define name="BibDataExtensionType">
970
+ <ref name="doctype"/>
971
+ </define>
972
+ <define name="doctype">
973
+ <element name="doctype">
974
+ <ref name="DocumentType"/>
975
+ </element>
976
+ </define>
977
+ <define name="DocumentType">
978
+ <value>document</value>
979
+ </define>
980
+ <define name="BibData">
981
+ <ref name="BibliographicItem"/>
982
+ <optional>
983
+ <ref name="ext"/>
984
+ </optional>
985
+ </define>
986
+ </grammar>