metanorma-unece 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.hound.yml +3 -0
  4. data/.rubocop.ribose.yml +66 -0
  5. data/.rubocop.tb.yml +650 -0
  6. data/.rubocop.yml +15 -0
  7. data/.travis.yml +21 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE +25 -0
  11. data/README.adoc +202 -0
  12. data/Rakefile +6 -0
  13. data/bin/console +14 -0
  14. data/bin/rspec +17 -0
  15. data/bin/setup +8 -0
  16. data/lib/asciidoctor/unece.rb +7 -0
  17. data/lib/asciidoctor/unece/biblio.rng +880 -0
  18. data/lib/asciidoctor/unece/converter.rb +240 -0
  19. data/lib/asciidoctor/unece/isodoc.rng +1066 -0
  20. data/lib/asciidoctor/unece/isostandard.rng +1054 -0
  21. data/lib/asciidoctor/unece/unece.rng +247 -0
  22. data/lib/isodoc/unece.rb +9 -0
  23. data/lib/isodoc/unece/html/header.html +164 -0
  24. data/lib/isodoc/unece/html/html_unece_intro.html +27 -0
  25. data/lib/isodoc/unece/html/html_unece_titlepage.html +112 -0
  26. data/lib/isodoc/unece/html/htmlstyle.scss +1119 -0
  27. data/lib/isodoc/unece/html/logo.jpg +0 -0
  28. data/lib/isodoc/unece/html/scripts.html +82 -0
  29. data/lib/isodoc/unece/html/unece.scss +660 -0
  30. data/lib/isodoc/unece/html/word_unece_intro.html +24 -0
  31. data/lib/isodoc/unece/html/word_unece_plenary_titlepage.html +129 -0
  32. data/lib/isodoc/unece/html/word_unece_titlepage.html +17 -0
  33. data/lib/isodoc/unece/html/wordstyle.scss +1088 -0
  34. data/lib/isodoc/unece/html_convert.rb +392 -0
  35. data/lib/isodoc/unece/metadata.rb +93 -0
  36. data/lib/isodoc/unece/word_convert.rb +405 -0
  37. data/lib/metanorma-unece.rb +8 -0
  38. data/lib/metanorma/unece.rb +11 -0
  39. data/lib/metanorma/unece/UN_emblem_blue.svg +193 -0
  40. data/lib/metanorma/unece/processor.rb +40 -0
  41. data/lib/metanorma/unece/version.rb +5 -0
  42. data/metanorma-unece.gemspec +47 -0
  43. metadata +353 -0
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
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
+ # Thoughtbot's style guide from: https://github.com/thoughtbot/guides
7
+ - ".rubocop.tb.yml"
8
+ # Overrides from Ribose
9
+ - ".rubocop.ribose.yml"
10
+ AllCops:
11
+ DisplayCopNames: false
12
+ StyleGuideCopsOnly: false
13
+ TargetRubyVersion: 2.5
14
+ Rails:
15
+ Enabled: true
data/.travis.yml ADDED
@@ -0,0 +1,21 @@
1
+ dist: trusty
2
+ sudo: false
3
+ language: ruby
4
+ rvm:
5
+ - 2.5
6
+ - 2.4
7
+ - 2.3
8
+ - ruby-head
9
+ before_install:
10
+ - gem install bundler -v 1.16.1
11
+ - unset _JAVA_OPTIONS
12
+ - wget "http://downloads.sourceforge.net/project/plantuml/plantuml.jar?r=&ts=1424308684&use_mirror=jaist" -O plantuml.jar
13
+ - sudo mkdir -p /opt/plantuml
14
+ - sudo cp plantuml.jar /opt/plantuml
15
+ - echo "#! /bin/sh" > plantuml.sh
16
+ - echo 'exec java -jar /opt/plantuml/plantuml.jar "$@"' >> plantuml.sh
17
+ - sudo install -m 755 -D plantuml.sh /usr/bin/plantuml
18
+ - plantuml -version
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: ruby-head
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ronald.tse@ribose.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) {|repo| "https://github.com/#{repo}" }
3
+
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc ADDED
@@ -0,0 +1,202 @@
1
+ = Metanorma processor for UNECE documents
2
+
3
+ image:https://img.shields.io/gem/v/metanorma-unece.svg["Gem Version", link="https://rubygems.org/gems/metanorma-unece"]
4
+ image:https://img.shields.io/travis/riboseinc/metanorma-unece/master.svg["Build Status", link="https://travis-ci.org/riboseinc/metanorma-unece"]
5
+ image:https://codeclimate.com/github/riboseinc/metanorma-unece/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/metanorma-unece"]
6
+
7
+ WARNING: This gem is still under development.
8
+
9
+
10
+ == Functionality
11
+
12
+ This gem processes http://asciidoctor.org/[Asciidoctor] documents following
13
+ a template for generating UNECE International Standards.
14
+
15
+ The gem currently inherits from the https://github.com/riboseinc/metanorma-standoc[Metanorma-Standoc]
16
+ gem, and aligns closely to it. Refer to the ISO gem documentation
17
+ for guidance, including https://github.com/riboseinc/metanorma-iso/wiki/Guidance-for-authoring[the Authoring Guide].
18
+
19
+ The following outputs are generated.
20
+
21
+ * (Optional) An HTML preview generated directly from the Asciidoctor document,
22
+ using native AsciiDoc formatting.
23
+ ** http://asciimath.org[AsciiMathML] is to be used for mathematical formatting.
24
+ The gem uses the https://github.com/asciidoctor/asciimath[Ruby AsciiMath parser],
25
+ which is syntactically stricter than the common MathJax processor;
26
+ if you do not get expected results, try bracketing terms your in AsciiMathML
27
+ expressions.
28
+
29
+ * an XML representation of the document, intended as a document model for UNECE
30
+ International Standards.
31
+
32
+ * The XML representation is processed in turn to generate the following outputs
33
+ as end deliverable UNECE standard drafts.
34
+ ** HTML
35
+ ** Word
36
+
37
+ This AsciiDoc syntax for writing UNECE standards is hereby named "AsciiUNECE".
38
+
39
+ == Usage
40
+
41
+ The preferred way to invoke this gem is via the `metanorma` script:
42
+
43
+ [source,console]
44
+ ----
45
+ $ metanorma --type unece a.adoc # output HTML and PDF
46
+ $ metanorma --type unece --extensions html a.adoc # output just HTML
47
+ $ metanorma --type unece --extensions pdf a.adoc # output just PDF
48
+ $ metanorma --type unece --extensions xml a.adoc # output UNECE XML
49
+ ----
50
+
51
+ The gem translates the document into UNECE XML format, and then
52
+ validates its output against the UNECE XML document model; errors are
53
+ reported to console against the XML, and are intended for users to
54
+ check that they have provided all necessary components of the
55
+ document.
56
+
57
+ The gem then converts the XML into HTML and PDF.
58
+
59
+ ////
60
+ The gem can also be invoked directly within asciidoctor, though this is deprecated:
61
+
62
+ [source,console]
63
+ ----
64
+ $ asciidoctor -b unece -r 'metanorma-unece' a.adoc
65
+ ----
66
+ ////
67
+
68
+ == Installation
69
+
70
+ === Quick start
71
+
72
+ https://www.metanorma.com/overview/getting-started/
73
+
74
+ === macOS
75
+
76
+ If you are using macOS, the https://github.com/riboseinc/metanorma-macos-setup
77
+ repository has instructions on setting up your machine to run Metanorma
78
+ scripts such as this one. You need only run the following in a Terminal console:
79
+
80
+ [source,console]
81
+ ----
82
+ $ bash <(curl -s https://raw.githubusercontent.com/riboseinc/metanorma-macos-setup/master/metanorma-setup)
83
+ $ gem install metanorma-unece
84
+ ----
85
+
86
+ === PDF output
87
+
88
+ PDF output is generated by printing the HTML output as PDF. This is done
89
+ within the gem, using
90
+ https://developers.google.com/web/updates/2017/04/headless-chrome[Headless Chrome],
91
+ via the https://github.com/GoogleChrome/puppeteer[Puppeteer] Node library.
92
+
93
+ To get the PDF output working, do the following:
94
+
95
+ * Install Node, with at least version 7.6.0: https://nodejs.org/en/download/,
96
+ https://nodejs.org/en/download/package-manager/ . (For Mac, `brew install node`)
97
+ * Install npm: https://docs.npmjs.com/getting-started/installing-node
98
+ * Install puppeteer: `npm install -g --save --save-exact puppeteer`
99
+
100
+ NOTE: The https://github.com/riboseinc/metanorma-macos-setup script already
101
+ includes Puppeteer installation.
102
+
103
+
104
+ == Approach
105
+
106
+ === Document model
107
+
108
+ The UNECE Standard Document model is an instance of the
109
+ https://github.com/riboseinc/metanorma-model-standoc[StandardDocument model].
110
+
111
+ The UNECE format ("UNECE XML") intends to introduce rigor into the UNECE
112
+ standards authoring process, and is prescribed in a separate document.
113
+
114
+ === Asciidoctor
115
+
116
+ Asciidoctor has been selected as the authoring tool to generate the document
117
+ model representation of UNECE standards. It is a document formatting tool like
118
+ Markdown and DocBook, which combines the relative ease of use of the former
119
+ (using relatively lightweight markup), and the rigor and expressively of the
120
+ latter (it has a well-defined syntax, and was in fact initially developed as a
121
+ DocBook document authoring tool). Asciidoctor has built-in capability to output
122
+ Text, DocBook and HTML; so it can be used to preview the file as it is being
123
+ authored.
124
+
125
+ Generating documents via a document model substantially automated formatting
126
+ associated with the document, including automating numbering of headings, figures,
127
+ tables etc, and automatically generating references and citations.
128
+
129
+ == Document Attributes
130
+
131
+ === Common attributes
132
+
133
+ The gem relies on Asciidoctor document attributes to provide necessary
134
+ metadata about the document. These include:
135
+
136
+ `:edition:`:: The document edition
137
+
138
+ `:revdate:`:: The date the document was last updated
139
+
140
+ `:copyright-year:`:: The year which will be claimed as when the copyright for
141
+ the document was issued
142
+
143
+ `:title:`:: The main component of the English title of the document
144
+ (mandatory). (The first line of the AsciiDoc document, which contains the title
145
+ introduced with `=`, is ignored)
146
+
147
+ `:doctype:`:: The document type (see _UNECE deliverables: The different types of
148
+ UNECE publications_) (mandatory). Note that the document types are reflected in the
149
+ document identifier. The permitted types are:
150
+ +
151
+ --
152
+ recommendation:: UNECE Recommendation
153
+ plenary:: UNECE Plenary document
154
+ --
155
+
156
+ `:status:``:: The document status. The permitted types are: `proposal`,
157
+ `working-draft`, `committee-draft`, `draft-standard`, `final-draft`,
158
+ `published`, `withdrawn`.
159
+
160
+ `:committee:`:: The name of the relevant UNECE committee, for example,
161
+ `United Nations Centre for Trade Facilitation and Electronic Business (UN/CEFACT)` (mandatory)
162
+
163
+ `:language:` :: The language of the document (only `en` for now) (mandatory)
164
+ `:script:` :: The language of the document (only `Latn` for now) (mandatory)
165
+
166
+ NOTE: The attribute `:draft:`, if present, includes review notes in the XML output;
167
+ these are otherwise suppressed.
168
+
169
+
170
+ === Recommendation specific attributes
171
+
172
+ `:docnumber:`:: The document number if the document is a Recommendation. e.g. `42` for Recommendation 42, which happens to be the ultimate answer. (mandatory for Recommendation)
173
+
174
+
175
+ === Plenary document specific attributes
176
+
177
+ `:session-date:`:: Date of the session where this document will be discussed. e.g. `Geneva, 30 April – 1 May 2018`
178
+
179
+ `:agenda-item:`:: Number of the agenda item this document belongs to. e.g. `Item 6 of the provisional agenda`
180
+
181
+ `:collaborator:`:: Collaborator of this document, if any. e.g. `World Economic Forum`
182
+
183
+ `:agenda-id:`:: The unique ID number of this agenda item. e.g. `ECE/TRADE/C/CEFACT/2018/6`
184
+
185
+ `:distribution:`:: Extent of distribution allowed. e.g. `General`
186
+
187
+
188
+ == Data Models
189
+
190
+ The UNECE Standard Document format is an instance of the
191
+ https://github.com/riboseinc/metanorma-model-standoc[StandardDocument model]. Details of
192
+ this general model can be found on its page.
193
+
194
+ Details of the UNECE modifications to this general model can be found in the
195
+ https://github.com/riboseinc/metanorma-model-unece[UNECE model]
196
+ repository.
197
+
198
+ == Examples
199
+
200
+ * link:spec/examples/plenary.adoc[] is the source file for the "`ECE/TRADE/C/CEFACT/2018/6`" plenary document.
201
+ * link:spec/examples/rec42.adoc[] is the source file for Recommendation 42.
202
+ * link:spec/examples/rfc6350.adoc[] is the UNECE version of https://tools.ietf.org/html/rfc6350[RFC 6350].
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "metanorma/unece"
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__)
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
+ "../../Gemfile", Pathname.new(__FILE__).realpath
12
+ )
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -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,7 @@
1
+ require "asciidoctor/unece/converter"
2
+
3
+ module Asciidoctor
4
+ module Unece
5
+
6
+ end
7
+ end
@@ -0,0 +1,880 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ instantiations of this grammar may replace leaf strings
4
+ with more elaborated types; e.g. title (text) replaced with
5
+ title-main, title-intro, title-part; type replaced with
6
+ enum.
7
+
8
+ some renaming at leaf nodes is permissible
9
+
10
+ obligations can change both from optional to mandatory,
11
+ and from mandatory to optional; optional elements may
12
+ be omitted; freely positioned alternatives may be replaced
13
+ with strict ordering
14
+
15
+ DO NOT introduce a namespace here. We do not want a distinct namespace
16
+ for these elements, and a distinct namespace for any grammar inheriting
17
+ these elements; we just want one namespace for any child grammars
18
+ of this.
19
+ -->
20
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
21
+ <define name="status">
22
+ <element name="status">
23
+ <ref name="LocalizedString"/>
24
+ </element>
25
+ </define>
26
+ <define name="language">
27
+ <element name="language">
28
+ <text/>
29
+ </element>
30
+ </define>
31
+ <define name="script">
32
+ <a:documentation>ISO-639</a:documentation>
33
+ <element name="script">
34
+ <text/>
35
+ </element>
36
+ </define>
37
+ <define name="edition">
38
+ <a:documentation>ISO-15924: Latn</a:documentation>
39
+ <element name="edition">
40
+ <text/>
41
+ </element>
42
+ </define>
43
+ <define name="LocalizedString">
44
+ <optional>
45
+ <!-- multiple languages and scripts possible: comma delimit them if so -->
46
+ <attribute name="language"/>
47
+ </optional>
48
+ <optional>
49
+ <attribute name="script"/>
50
+ </optional>
51
+ <text/>
52
+ </define>
53
+ <!--
54
+ Unlike UML, change type to format: type is overloaded
55
+ Would be need if plain were default value and could omit the attribute
56
+ Added LocalizedStringOrXsAny
57
+ -->
58
+ <define name="FormattedString">
59
+ <optional>
60
+ <!-- attribute format { ( "plain" | "html" | "docbook" | "tei" | "asciidoc" | "markdown" ) }?, -->
61
+ <attribute name="format">
62
+ <choice>
63
+ <value>text/plain</value>
64
+ <value>text/html</value>
65
+ <value>application/docbook+xml</value>
66
+ <value>application/tei+xml</value>
67
+ <value>text/x-asciidoc</value>
68
+ <value>text/markdown</value>
69
+ <value>application/x-isodoc+xml</value>
70
+ <text/>
71
+ </choice>
72
+ </attribute>
73
+ </optional>
74
+ <ref name="LocalizedStringOrXsAny"/>
75
+ </define>
76
+ <define name="LocalizedStringOrXsAny">
77
+ <optional>
78
+ <!-- multiple languages and scripts possible: comma delimit them if so -->
79
+ <attribute name="language"/>
80
+ </optional>
81
+ <optional>
82
+ <attribute name="script"/>
83
+ </optional>
84
+ <oneOrMore>
85
+ <choice>
86
+ <text/>
87
+ <ref name="AnyElement"/>
88
+ </choice>
89
+ </oneOrMore>
90
+ </define>
91
+ <define name="contributor">
92
+ <element name="contributor">
93
+ <zeroOrMore>
94
+ <ref name="role"/>
95
+ </zeroOrMore>
96
+ <ref name="ContributorInfo"/>
97
+ </element>
98
+ </define>
99
+ <define name="role">
100
+ <element name="role">
101
+ <optional>
102
+ <attribute name="type">
103
+ <choice>
104
+ <value>author</value>
105
+ <value>performer</value>
106
+ <value>publisher</value>
107
+ <value>editor</value>
108
+ <value>adapter</value>
109
+ <value>translator</value>
110
+ <value>distributor</value>
111
+ </choice>
112
+ </attribute>
113
+ </optional>
114
+ <zeroOrMore>
115
+ <ref name="roledescription"/>
116
+ </zeroOrMore>
117
+ </element>
118
+ </define>
119
+ <define name="ContributorInfo">
120
+ <choice>
121
+ <ref name="person"/>
122
+ <ref name="organization"/>
123
+ </choice>
124
+ </define>
125
+ <define name="roledescription">
126
+ <element name="description">
127
+ <ref name="FormattedString"/>
128
+ </element>
129
+ </define>
130
+ <define name="person">
131
+ <element name="person">
132
+ <optional>
133
+ <ref name="fullname"/>
134
+ </optional>
135
+ <zeroOrMore>
136
+ <ref name="affiliation"/>
137
+ </zeroOrMore>
138
+ <zeroOrMore>
139
+ <ref name="person-identifier"/>
140
+ </zeroOrMore>
141
+ <zeroOrMore>
142
+ <ref name="contact"/>
143
+ </zeroOrMore>
144
+ <optional>
145
+ <ref name="uri"/>
146
+ </optional>
147
+ </element>
148
+ </define>
149
+ <define name="fullname">
150
+ <element name="name">
151
+ <choice>
152
+ <group>
153
+ <zeroOrMore>
154
+ <ref name="prefix"/>
155
+ </zeroOrMore>
156
+ <zeroOrMore>
157
+ <ref name="forename"/>
158
+ </zeroOrMore>
159
+ <zeroOrMore>
160
+ <ref name="initial"/>
161
+ </zeroOrMore>
162
+ <ref name="surname"/>
163
+ <zeroOrMore>
164
+ <ref name="addition"/>
165
+ </zeroOrMore>
166
+ </group>
167
+ <ref name="completeName"/>
168
+ </choice>
169
+ <zeroOrMore>
170
+ <ref name="biblionote"/>
171
+ </zeroOrMore>
172
+ </element>
173
+ </define>
174
+ <define name="prefix">
175
+ <element name="prefix">
176
+ <ref name="LocalizedString"/>
177
+ </element>
178
+ </define>
179
+ <define name="initial">
180
+ <element name="initial">
181
+ <ref name="LocalizedString"/>
182
+ </element>
183
+ </define>
184
+ <define name="addition">
185
+ <element name="addition">
186
+ <ref name="LocalizedString"/>
187
+ </element>
188
+ </define>
189
+ <define name="surname">
190
+ <element name="surname">
191
+ <ref name="LocalizedString"/>
192
+ </element>
193
+ </define>
194
+ <define name="forename">
195
+ <element name="forename">
196
+ <ref name="LocalizedString"/>
197
+ </element>
198
+ </define>
199
+ <define name="completeName">
200
+ <element name="completename">
201
+ <ref name="LocalizedString"/>
202
+ </element>
203
+ </define>
204
+ <define name="affiliation">
205
+ <element name="affiliation">
206
+ <optional>
207
+ <ref name="affiliationname"/>
208
+ </optional>
209
+ <zeroOrMore>
210
+ <ref name="affiliationdescription"/>
211
+ </zeroOrMore>
212
+ <ref name="organization"/>
213
+ </element>
214
+ </define>
215
+ <define name="affiliationname">
216
+ <element name="name">
217
+ <ref name="LocalizedString"/>
218
+ </element>
219
+ </define>
220
+ <define name="affiliationdescription">
221
+ <element name="description">
222
+ <ref name="FormattedString"/>
223
+ </element>
224
+ </define>
225
+ <define name="organization">
226
+ <element name="organization">
227
+ <ref name="orgname"/>
228
+ <optional>
229
+ <ref name="subdivision"/>
230
+ </optional>
231
+ <optional>
232
+ <ref name="abbreviation"/>
233
+ </optional>
234
+ <optional>
235
+ <ref name="uri"/>
236
+ </optional>
237
+ <zeroOrMore>
238
+ <ref name="org-identifier"/>
239
+ </zeroOrMore>
240
+ <zeroOrMore>
241
+ <ref name="contact"/>
242
+ </zeroOrMore>
243
+ </element>
244
+ </define>
245
+ <define name="orgname">
246
+ <element name="name">
247
+ <ref name="LocalizedString"/>
248
+ </element>
249
+ </define>
250
+ <define name="subdivision">
251
+ <element name="subdivision">
252
+ <ref name="LocalizedString"/>
253
+ </element>
254
+ </define>
255
+ <define name="abbreviation">
256
+ <element name="abbreviation">
257
+ <ref name="LocalizedString"/>
258
+ </element>
259
+ </define>
260
+ <define name="uri">
261
+ <element name="uri">
262
+ <optional>
263
+ <attribute name="type"/>
264
+ </optional>
265
+ <data type="anyURI"/>
266
+ </element>
267
+ </define>
268
+ <!-- TODO may change -->
269
+ <define name="contact">
270
+ <choice>
271
+ <ref name="address"/>
272
+ <ref name="phone"/>
273
+ <ref name="email"/>
274
+ <ref name="uri"/>
275
+ </choice>
276
+ </define>
277
+ <define name="phone">
278
+ <element name="phone">
279
+ <text/>
280
+ </element>
281
+ </define>
282
+ <define name="email">
283
+ <element name="email">
284
+ <text/>
285
+ </element>
286
+ </define>
287
+ <define name="address">
288
+ <element name="address">
289
+ <oneOrMore>
290
+ <!-- iso191606 TODO -->
291
+ <ref name="street"/>
292
+ </oneOrMore>
293
+ <ref name="city"/>
294
+ <optional>
295
+ <ref name="state"/>
296
+ </optional>
297
+ <ref name="country"/>
298
+ <optional>
299
+ <ref name="postcode"/>
300
+ </optional>
301
+ </element>
302
+ </define>
303
+ <define name="street">
304
+ <element name="street">
305
+ <text/>
306
+ </element>
307
+ </define>
308
+ <define name="city">
309
+ <element name="city">
310
+ <text/>
311
+ </element>
312
+ </define>
313
+ <define name="state">
314
+ <element name="state">
315
+ <text/>
316
+ </element>
317
+ </define>
318
+ <define name="country">
319
+ <element name="country">
320
+ <text/>
321
+ </element>
322
+ </define>
323
+ <define name="postcode">
324
+ <element name="postcode">
325
+ <text/>
326
+ </element>
327
+ </define>
328
+ <define name="person-identifier">
329
+ <element name="identifier">
330
+ <attribute name="type">
331
+ <choice>
332
+ <value>isni</value>
333
+ <value>uri</value>
334
+ </choice>
335
+ </attribute>
336
+ <text/>
337
+ </element>
338
+ </define>
339
+ <define name="org-identifier">
340
+ <element name="identifier">
341
+ <attribute name="type">
342
+ <choice>
343
+ <value>orcid</value>
344
+ <value>uri</value>
345
+ </choice>
346
+ </attribute>
347
+ <text/>
348
+ </element>
349
+ </define>
350
+ <define name="citation">
351
+ <element name="citation">
352
+ <ref name="CitationType"/>
353
+ </element>
354
+ </define>
355
+ <define name="CitationType">
356
+ <attribute name="bibitemid">
357
+ <data type="IDREF"/>
358
+ </attribute>
359
+ <zeroOrMore>
360
+ <ref name="locality"/>
361
+ </zeroOrMore>
362
+ <optional>
363
+ <ref name="date"/>
364
+ </optional>
365
+ </define>
366
+ <define name="date">
367
+ <element name="date">
368
+ <choice>
369
+ <data type="gYear"/>
370
+ <data type="date"/>
371
+ </choice>
372
+ </element>
373
+ </define>
374
+ <define name="locality">
375
+ <element name="locality">
376
+ <ref name="BibItemLocality"/>
377
+ </element>
378
+ </define>
379
+ <define name="BibItemLocality">
380
+ <attribute name="type">
381
+ <ref name="LocalityType"/>
382
+ </attribute>
383
+ <ref name="referenceFrom"/>
384
+ <optional>
385
+ <ref name="referenceTo"/>
386
+ </optional>
387
+ </define>
388
+ <define name="LocalityType">
389
+ <data type="string">
390
+ <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|locality:[a-zA-Z0-9_]+</param>
391
+ </data>
392
+ </define>
393
+ <define name="referenceFrom">
394
+ <element name="referenceFrom">
395
+ <text/>
396
+ </element>
397
+ </define>
398
+ <define name="referenceTo">
399
+ <element name="referenceTo">
400
+ <text/>
401
+ </element>
402
+ </define>
403
+ <!-- unlike UML, has id attribute; that results from including bibitem in a docmodel -->
404
+ <define name="bibitem">
405
+ <element name="bibitem">
406
+ <attribute name="id">
407
+ <data type="ID"/>
408
+ </attribute>
409
+ <ref name="BibliographicItem"/>
410
+ </element>
411
+ </define>
412
+ <define name="bibitem_no_id">
413
+ <element name="bibitem">
414
+ <ref name="BibliographicItem"/>
415
+ </element>
416
+ </define>
417
+ <define name="relaton_collection">
418
+ <element name="relaton-collection">
419
+ <optional>
420
+ <attribute name="type"/>
421
+ </optional>
422
+ <ref name="btitle"/>
423
+ <zeroOrMore>
424
+ <ref name="contributor"/>
425
+ </zeroOrMore>
426
+ <zeroOrMore>
427
+ <ref name="docrelation"/>
428
+ </zeroOrMore>
429
+ </element>
430
+ </define>
431
+ <define name="BibItemType" combine="choice">
432
+ <choice>
433
+ <value>article</value>
434
+ <value>book</value>
435
+ <value>booklet</value>
436
+ <value>conference</value>
437
+ <value>manual</value>
438
+ <value>proceedings</value>
439
+ <value>presentation</value>
440
+ <value>thesis</value>
441
+ <value>techreport</value>
442
+ <value>standard</value>
443
+ <value>unpublished</value>
444
+ <value>map</value>
445
+ <value>electronic resource</value>
446
+ <value>audiovisual</value>
447
+ <value>film</value>
448
+ <value>video</value>
449
+ <value>broadcast</value>
450
+ <value>graphic work</value>
451
+ <value>music</value>
452
+ <value>patent</value>
453
+ <value>inbook</value>
454
+ <value>incollection</value>
455
+ <value>inproceedings</value>
456
+ </choice>
457
+ </define>
458
+ <define name="BibliographicItem">
459
+ <optional>
460
+ <attribute name="type">
461
+ <ref name="BibItemType"/>
462
+ </attribute>
463
+ </optional>
464
+ <optional>
465
+ <ref name="fetched"/>
466
+ </optional>
467
+ <choice>
468
+ <oneOrMore>
469
+ <ref name="btitle"/>
470
+ </oneOrMore>
471
+ <ref name="formattedref"/>
472
+ </choice>
473
+ <zeroOrMore>
474
+ <ref name="bsource"/>
475
+ </zeroOrMore>
476
+ <zeroOrMore>
477
+ <ref name="docidentifier"/>
478
+ </zeroOrMore>
479
+ <zeroOrMore>
480
+ <ref name="bdate"/>
481
+ </zeroOrMore>
482
+ <zeroOrMore>
483
+ <ref name="contributor"/>
484
+ </zeroOrMore>
485
+ <optional>
486
+ <ref name="edition"/>
487
+ </optional>
488
+ <zeroOrMore>
489
+ <ref name="biblionote"/>
490
+ </zeroOrMore>
491
+ <zeroOrMore>
492
+ <ref name="language"/>
493
+ </zeroOrMore>
494
+ <zeroOrMore>
495
+ <ref name="script"/>
496
+ </zeroOrMore>
497
+ <optional>
498
+ <ref name="abstract"/>
499
+ </optional>
500
+ <optional>
501
+ <ref name="status"/>
502
+ </optional>
503
+ <optional>
504
+ <ref name="copyright"/>
505
+ </optional>
506
+ <zeroOrMore>
507
+ <ref name="docrelation"/>
508
+ </zeroOrMore>
509
+ <zeroOrMore>
510
+ <ref name="series"/>
511
+ </zeroOrMore>
512
+ <optional>
513
+ <ref name="medium"/>
514
+ </optional>
515
+ <zeroOrMore>
516
+ <ref name="bplace"/>
517
+ </zeroOrMore>
518
+ <zeroOrMore>
519
+ <ref name="extent"/>
520
+ </zeroOrMore>
521
+ <zeroOrMore>
522
+ <ref name="accesslocation"/>
523
+ </zeroOrMore>
524
+ <optional>
525
+ <ref name="bclassification"/>
526
+ </optional>
527
+ <optional>
528
+ <ref name="validity"/>
529
+ </optional>
530
+ </define>
531
+ <define name="btitle">
532
+ <element name="title">
533
+ <ref name="TypedTitleString"/>
534
+ </element>
535
+ </define>
536
+ <define name="bsource">
537
+ <element name="uri">
538
+ <ref name="TypedUri"/>
539
+ </element>
540
+ </define>
541
+ <define name="formattedref">
542
+ <element name="formattedref">
543
+ <ref name="FormattedString"/>
544
+ </element>
545
+ </define>
546
+ <define name="fetched">
547
+ <element name="fetched">
548
+ <choice>
549
+ <data type="dateTime"/>
550
+ <data type="date"/>
551
+ </choice>
552
+ </element>
553
+ </define>
554
+ <define name="validity">
555
+ <element name="validity">
556
+ <optional>
557
+ <ref name="validityBegins"/>
558
+ </optional>
559
+ <optional>
560
+ <ref name="validityEnds"/>
561
+ </optional>
562
+ <optional>
563
+ <ref name="validityRevision"/>
564
+ </optional>
565
+ </element>
566
+ </define>
567
+ <define name="validityBegins">
568
+ <element name="validityBegins">
569
+ <choice>
570
+ <data type="dateTime"/>
571
+ <data type="date"/>
572
+ </choice>
573
+ </element>
574
+ </define>
575
+ <define name="validityEnds">
576
+ <element name="validityEnds">
577
+ <choice>
578
+ <data type="dateTime"/>
579
+ <data type="date"/>
580
+ </choice>
581
+ </element>
582
+ </define>
583
+ <define name="validityRevision">
584
+ <element name="revision">
585
+ <choice>
586
+ <data type="dateTime"/>
587
+ <data type="date"/>
588
+ </choice>
589
+ </element>
590
+ </define>
591
+ <define name="TypedTitleString">
592
+ <optional>
593
+ <attribute name="type">
594
+ <ref name="TitleType"/>
595
+ </attribute>
596
+ </optional>
597
+ <ref name="FormattedString"/>
598
+ </define>
599
+ <define name="TitleType">
600
+ <choice>
601
+ <value>alternative</value>
602
+ <value>original</value>
603
+ <value>unofficial</value>
604
+ <value>subtitle</value>
605
+ <value>main</value>
606
+ </choice>
607
+ </define>
608
+ <define name="TypedUri">
609
+ <optional>
610
+ <attribute name="type"/>
611
+ </optional>
612
+ <data type="anyURI"/>
613
+ </define>
614
+ <define name="DateType">
615
+ <optional>
616
+ <attribute name="text"/>
617
+ </optional>
618
+ <optional>
619
+ <choice>
620
+ <data type="gYear"/>
621
+ <data type="date"/>
622
+ </choice>
623
+ </optional>
624
+ </define>
625
+ <define name="bdate">
626
+ <element name="date">
627
+ <attribute name="type">
628
+ <choice>
629
+ <value>published</value>
630
+ <value>accessed</value>
631
+ <value>created</value>
632
+ <value>implemented</value>
633
+ <value>obsoleted</value>
634
+ <value>confirmed</value>
635
+ <value>updated</value>
636
+ <value>issued</value>
637
+ <value>transmitted</value>
638
+ <value>copied</value>
639
+ <value>unchanged</value>
640
+ </choice>
641
+ </attribute>
642
+ <choice>
643
+ <group>
644
+ <element name="from">
645
+ <choice>
646
+ <data type="gYear"/>
647
+ <data type="date"/>
648
+ </choice>
649
+ </element>
650
+ <optional>
651
+ <element name="to">
652
+ <choice>
653
+ <data type="gYear"/>
654
+ <data type="date"/>
655
+ </choice>
656
+ </element>
657
+ </optional>
658
+ </group>
659
+ <element name="on">
660
+ <choice>
661
+ <data type="gYear"/>
662
+ <data type="date"/>
663
+ </choice>
664
+ </element>
665
+ </choice>
666
+ </element>
667
+ </define>
668
+ <define name="docidentifier">
669
+ <element name="docidentifier">
670
+ <optional>
671
+ <attribute name="type"/>
672
+ </optional>
673
+ <text/>
674
+ </element>
675
+ </define>
676
+ <define name="bclassification">
677
+ <element name="classification">
678
+ <optional>
679
+ <attribute name="type"/>
680
+ </optional>
681
+ <text/>
682
+ </element>
683
+ </define>
684
+ <define name="bplace">
685
+ <element name="place">
686
+ <text/>
687
+ </element>
688
+ </define>
689
+ <define name="medium">
690
+ <element name="medium">
691
+ <optional>
692
+ <ref name="form"/>
693
+ </optional>
694
+ <optional>
695
+ <ref name="size"/>
696
+ </optional>
697
+ <optional>
698
+ <ref name="scale"/>
699
+ </optional>
700
+ </element>
701
+ </define>
702
+ <define name="form">
703
+ <element name="form">
704
+ <text/>
705
+ </element>
706
+ </define>
707
+ <define name="size">
708
+ <element name="size">
709
+ <text/>
710
+ </element>
711
+ </define>
712
+ <define name="scale">
713
+ <element name="scale">
714
+ <text/>
715
+ </element>
716
+ </define>
717
+ <define name="accesslocation">
718
+ <element name="accesslocation">
719
+ <text/>
720
+ </element>
721
+ </define>
722
+ <define name="extent">
723
+ <element name="extent">
724
+ <ref name="BibItemLocality"/>
725
+ </element>
726
+ </define>
727
+ <define name="series">
728
+ <element name="series">
729
+ <optional>
730
+ <attribute name="type">
731
+ <choice>
732
+ <value>main</value>
733
+ <value>alt</value>
734
+ </choice>
735
+ </attribute>
736
+ </optional>
737
+ <choice>
738
+ <ref name="btitle"/>
739
+ <ref name="formattedref"/>
740
+ </choice>
741
+ <optional>
742
+ <ref name="bplace"/>
743
+ </optional>
744
+ <optional>
745
+ <ref name="seriesorganization"/>
746
+ </optional>
747
+ <optional>
748
+ <ref name="abbreviation"/>
749
+ </optional>
750
+ <optional>
751
+ <ref name="seriesfrom"/>
752
+ </optional>
753
+ <optional>
754
+ <ref name="seriesto"/>
755
+ </optional>
756
+ <optional>
757
+ <ref name="seriesnumber"/>
758
+ </optional>
759
+ <optional>
760
+ <ref name="seriespartnumber"/>
761
+ </optional>
762
+ </element>
763
+ </define>
764
+ <define name="seriesorganization">
765
+ <element name="organization">
766
+ <text/>
767
+ </element>
768
+ </define>
769
+ <define name="seriesfrom">
770
+ <element name="from">
771
+ <choice>
772
+ <data type="dateTime"/>
773
+ <data type="date"/>
774
+ <data type="gYear"/>
775
+ </choice>
776
+ </element>
777
+ </define>
778
+ <define name="seriesto">
779
+ <element name="to">
780
+ <choice>
781
+ <data type="dateTime"/>
782
+ <data type="date"/>
783
+ <data type="gYear"/>
784
+ </choice>
785
+ </element>
786
+ </define>
787
+ <define name="seriesnumber">
788
+ <element name="number">
789
+ <text/>
790
+ </element>
791
+ </define>
792
+ <define name="seriespartnumber">
793
+ <element name="partnumber">
794
+ <text/>
795
+ </element>
796
+ </define>
797
+ <define name="biblionote">
798
+ <element name="note">
799
+ <ref name="FormattedString"/>
800
+ </element>
801
+ </define>
802
+ <define name="abstract">
803
+ <element name="abstract">
804
+ <ref name="FormattedString"/>
805
+ </element>
806
+ </define>
807
+ <define name="copyright">
808
+ <element name="copyright">
809
+ <ref name="from"/>
810
+ <optional>
811
+ <ref name="to"/>
812
+ </optional>
813
+ <ref name="owner"/>
814
+ </element>
815
+ </define>
816
+ <define name="from">
817
+ <element name="from">
818
+ <data type="gYear"/>
819
+ </element>
820
+ </define>
821
+ <define name="to">
822
+ <element name="to">
823
+ <data type="gYear"/>
824
+ </element>
825
+ </define>
826
+ <define name="owner">
827
+ <element name="owner">
828
+ <ref name="ContributorInfo"/>
829
+ </element>
830
+ </define>
831
+ <define name="docrelation">
832
+ <element name="relation">
833
+ <attribute name="type">
834
+ <choice>
835
+ <value>obsoletes</value>
836
+ <value>updates</value>
837
+ <value>updatedBy</value>
838
+ <value>complements</value>
839
+ <value>derivedFrom</value>
840
+ <value>translatedFrom</value>
841
+ <value>adoptedFrom</value>
842
+ <value>equivalent</value>
843
+ <value>identical</value>
844
+ <value>nonequivalent</value>
845
+ <value>includedIn</value>
846
+ <value>includes</value>
847
+ <value>instance</value>
848
+ <value>partOf</value>
849
+ </choice>
850
+ </attribute>
851
+ <element name="bibitem">
852
+ <ref name="BibliographicItem"/>
853
+ </element>
854
+ <zeroOrMore>
855
+ <ref name="locality"/>
856
+ </zeroOrMore>
857
+ </element>
858
+ </define>
859
+ <!--
860
+ Anycontents = mixed {
861
+ https://github.com/relaxng/jing-trang/issues/211
862
+ https://lists.oasis-open.org/archives/office/200808/msg00024.html
863
+ https://lists.oasis-open.org/archives/office/200808/msg00099.html
864
+ For this to work, we will actually strip any attributes in the Anycontents before
865
+ passing it for validation. Horrible I know, but there are no good alternatives
866
+ that also allow us to do grammar inheritance
867
+ (attribute * { text } | Any)*
868
+ Any*
869
+ }
870
+ -->
871
+ <define name="AnyElement">
872
+ <element>
873
+ <anyName/>
874
+ <choice>
875
+ <text/>
876
+ <ref name="AnyElement"/>
877
+ </choice>
878
+ </element>
879
+ </define>
880
+ </grammar>