rng 0.1.1 → 0.1.2

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.rubocop_todo.yml +64 -0
  4. data/CODE_OF_CONDUCT.md +132 -0
  5. data/Gemfile +3 -1
  6. data/README.adoc +402 -0
  7. data/lib/rng/any_name.rb +26 -0
  8. data/lib/rng/attribute.rb +58 -4
  9. data/lib/rng/choice.rb +60 -0
  10. data/lib/rng/data.rb +32 -0
  11. data/lib/rng/define.rb +51 -3
  12. data/lib/rng/element.rb +62 -16
  13. data/lib/rng/empty.rb +23 -0
  14. data/lib/rng/except.rb +62 -0
  15. data/lib/rng/external_ref.rb +28 -0
  16. data/lib/rng/grammar.rb +36 -0
  17. data/lib/rng/group.rb +60 -0
  18. data/lib/rng/include.rb +24 -0
  19. data/lib/rng/interleave.rb +58 -0
  20. data/lib/rng/list.rb +56 -0
  21. data/lib/rng/mixed.rb +58 -0
  22. data/lib/rng/name.rb +28 -0
  23. data/lib/rng/not_allowed.rb +23 -0
  24. data/lib/rng/ns_name.rb +31 -0
  25. data/lib/rng/one_or_more.rb +58 -0
  26. data/lib/rng/optional.rb +58 -0
  27. data/lib/rng/param.rb +30 -0
  28. data/lib/rng/parent_ref.rb +28 -0
  29. data/lib/rng/parse_rnc.rb +26 -0
  30. data/lib/rng/pattern.rb +24 -0
  31. data/lib/rng/ref.rb +28 -0
  32. data/lib/rng/rnc_parser.rb +351 -94
  33. data/lib/rng/start.rb +54 -5
  34. data/lib/rng/text.rb +26 -0
  35. data/lib/rng/to_rnc.rb +55 -0
  36. data/lib/rng/value.rb +29 -0
  37. data/lib/rng/version.rb +1 -1
  38. data/lib/rng/zero_or_more.rb +58 -0
  39. data/lib/rng.rb +29 -5
  40. data/rng.gemspec +3 -2
  41. data/spec/fixtures/rnc/address_book.rnc +10 -0
  42. data/spec/fixtures/rnc/complex_example.rnc +61 -0
  43. data/spec/fixtures/rng/address_book.rng +20 -0
  44. data/spec/fixtures/rng/relaxng.rng +335 -0
  45. data/spec/fixtures/rng/testSuite.rng +163 -0
  46. data/spec/fixtures/spectest.xml +6845 -0
  47. data/spec/rng/rnc_parser_spec.rb +6 -4
  48. data/spec/rng/rnc_roundtrip_spec.rb +121 -0
  49. data/spec/rng/schema_spec.rb +115 -166
  50. data/spec/rng/spectest_spec.rb +195 -0
  51. data/spec/spec_helper.rb +33 -0
  52. metadata +54 -7
  53. data/lib/rng/builder.rb +0 -158
  54. data/lib/rng/rng_parser.rb +0 -107
  55. data/lib/rng/schema.rb +0 -18
  56. data/spec/rng/rng_parser_spec.rb +0 -102
data/lib/rng/attribute.rb CHANGED
@@ -1,13 +1,67 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "lutaml/model"
2
4
 
3
5
  module Rng
4
6
  class Attribute < Lutaml::Model::Serializable
5
- attribute :name, :string
6
- attribute :type, :string, collection: true
7
+ attribute :name, Name
8
+ attribute :attr_name, :string
9
+ attribute :ns, :string
10
+ attribute :datatypeLibrary, :string
11
+ attribute :id, :string
12
+ attribute :ns_name, NsName
13
+ attribute :ref, Ref
14
+ attribute :choice, Choice
15
+ attribute :group, Group
16
+ attribute :interleave, Interleave
17
+ attribute :mixed, Mixed
18
+ attribute :optional, Optional
19
+ attribute :zeroOrMore, ZeroOrMore
20
+ attribute :oneOrMore, OneOrMore
21
+ attribute :anyName, AnyName
22
+ attribute :text, Text
23
+ attribute :empty, Empty
24
+ attribute :value, Value
25
+ attribute :data, Data
26
+ attribute :list, List
27
+ attribute :notAllowed, NotAllowed
28
+ attribute :attribute, Attribute
7
29
 
8
30
  xml do
9
- map_attribute "name", to: :name
10
- map_element "data", to: :type
31
+ root "attribute", ordered: true
32
+ namespace "http://relaxng.org/ns/structure/1.0"
33
+
34
+ map_element "name", to: :name
35
+ map_attribute "name", to: :attr_name
36
+ map_attribute "ns", to: :ns, value_map: {
37
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
38
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
39
+ }
40
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
41
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
42
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
43
+ }
44
+ map_attribute "id", to: :id
45
+ map_element "ref", to: :ref
46
+ map_element "choice", to: :choice
47
+ map_element "group", to: :group
48
+ map_element "interleave", to: :interleave
49
+ map_element "mixed", to: :mixed
50
+ map_element "optional", to: :optional
51
+ map_element "zeroOrMore", to: :zeroOrMore
52
+ map_element "oneOrMore", to: :oneOrMore
53
+ map_element "anyName", to: :anyName
54
+ map_element "text", to: :text, value_map: {
55
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
56
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
57
+ }
58
+ map_element "empty", to: :empty
59
+ map_element "value", to: :value
60
+ map_element "data", to: :data
61
+ map_element "list", to: :list
62
+ map_element "notAllowed", to: :notAllowed
63
+ map_element "attribute", to: :attribute
64
+ map_element "nsName", to: :ns_name
11
65
  end
12
66
  end
13
67
  end
data/lib/rng/choice.rb ADDED
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Choice < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+ attribute :element, Element, collection: true, initialize_empty: true
11
+ attribute :attribute, Attribute, collection: true, initialize_empty: true
12
+ attribute :ref, Ref, collection: true, initialize_empty: true
13
+ attribute :choice, Choice, collection: true, initialize_empty: true
14
+ attribute :group, Group, collection: true, initialize_empty: true
15
+ attribute :interleave, Interleave, collection: true, initialize_empty: true
16
+ attribute :mixed, Mixed, collection: true, initialize_empty: true
17
+ attribute :optional, Optional, collection: true, initialize_empty: true
18
+ attribute :zeroOrMore, ZeroOrMore, collection: true, initialize_empty: true
19
+ attribute :oneOrMore, OneOrMore, collection: true, initialize_empty: true
20
+ attribute :text, Text, collection: true, initialize_empty: true
21
+ attribute :empty, Empty, collection: true, initialize_empty: true
22
+ attribute :value, Value, collection: true, initialize_empty: true
23
+ attribute :data, Data, collection: true, initialize_empty: true
24
+ attribute :list, List, collection: true, initialize_empty: true
25
+ attribute :notAllowed, NotAllowed, collection: true, initialize_empty: true
26
+ attribute :name, Name, collection: true, initialize_empty: true
27
+
28
+ xml do
29
+ root "choice", ordered: true
30
+ namespace "http://relaxng.org/ns/structure/1.0"
31
+
32
+ map_attribute "id", to: :id
33
+ map_attribute "ns", to: :ns, value_map: {
34
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
35
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
36
+ }
37
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
38
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
39
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
40
+ }
41
+ map_element "element", to: :element
42
+ map_element "attribute", to: :attribute
43
+ map_element "ref", to: :ref
44
+ map_element "choice", to: :choice
45
+ map_element "group", to: :group
46
+ map_element "interleave", to: :interleave
47
+ map_element "mixed", to: :mixed
48
+ map_element "optional", to: :optional
49
+ map_element "zeroOrMore", to: :zeroOrMore
50
+ map_element "oneOrMore", to: :oneOrMore
51
+ map_element "text", to: :text
52
+ map_element "empty", to: :empty
53
+ map_element "value", to: :value
54
+ map_element "data", to: :data
55
+ map_element "list", to: :list
56
+ map_element "notAllowed", to: :notAllowed
57
+ map_element "name", to: :name
58
+ end
59
+ end
60
+ end
data/lib/rng/data.rb ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Data < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+ attribute :type, :string
11
+ attribute :param, Param, collection: true, initialize_empty: true
12
+ attribute :except, Except
13
+
14
+ xml do
15
+ root "data", ordered: true
16
+ namespace "http://relaxng.org/ns/structure/1.0"
17
+
18
+ map_attribute "id", to: :id
19
+ map_attribute "ns", to: :ns, value_map: {
20
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
21
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
22
+ }
23
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
24
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
25
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
26
+ }
27
+ map_attribute "type", to: :type
28
+ map_element "param", to: :param
29
+ map_element "except", to: :except
30
+ end
31
+ end
32
+ end
data/lib/rng/define.rb CHANGED
@@ -1,14 +1,62 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "lutaml/model"
2
- require_relative "element"
3
4
 
4
5
  module Rng
5
6
  class Define < Lutaml::Model::Serializable
6
7
  attribute :name, :string
7
- attribute :elements, Element, collection: true
8
+ attribute :combine, :string
9
+ attribute :id, :string
10
+ attribute :ns, :string
11
+ attribute :datatypeLibrary, :string
12
+ attribute :ref, Ref
13
+ attribute :element, Element, collection: true
14
+ attribute :choice, Choice
15
+ attribute :group, Group
16
+ attribute :interleave, Interleave
17
+ attribute :mixed, Mixed
18
+ attribute :optional, Optional
19
+ attribute :zeroOrMore, ZeroOrMore
20
+ attribute :oneOrMore, OneOrMore
21
+ attribute :text, Text
22
+ attribute :empty, Empty
23
+ attribute :value, Value
24
+ attribute :data, Data
25
+ attribute :list, List
26
+ attribute :notAllowed, NotAllowed
27
+ attribute :attribute, Attribute
28
+ attribute :grammar, Grammar
8
29
 
9
30
  xml do
31
+ root "define", ordered: true
10
32
  map_attribute "name", to: :name
11
- map_element "element", to: :elements
33
+ map_attribute "combine", to: :combine
34
+ map_attribute "id", to: :id
35
+ map_attribute "ns", to: :ns, value_map: {
36
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
37
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
38
+ }
39
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
40
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
41
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
42
+ }
43
+ map_element "ref", to: :ref
44
+ map_element "element", to: :element
45
+ map_element "choice", to: :choice
46
+ map_element "group", to: :group
47
+ map_element "interleave", to: :interleave
48
+ map_element "mixed", to: :mixed
49
+ map_element "optional", to: :optional
50
+ map_element "zeroOrMore", to: :zeroOrMore
51
+ map_element "oneOrMore", to: :oneOrMore
52
+ map_element "text", to: :text
53
+ map_element "empty", to: :empty
54
+ map_element "value", to: :value
55
+ map_element "data", to: :data
56
+ map_element "list", to: :list
57
+ map_element "notAllowed", to: :notAllowed
58
+ map_element "attribute", to: :attribute
59
+ map_element "grammar", to: :grammar
12
60
  end
13
61
  end
14
62
  end
data/lib/rng/element.rb CHANGED
@@ -1,26 +1,72 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "lutaml/model"
2
- require_relative "attribute"
3
4
 
4
5
  module Rng
5
6
  class Element < Lutaml::Model::Serializable
6
- attribute :name, :string
7
- attribute :attributes, Attribute, collection: true
8
- attribute :elements, Element, collection: true
9
- attribute :text, :boolean
10
- attribute :zero_or_more, Element, collection: true
11
- attribute :one_or_more, Element, collection: true
12
- attribute :optional, Element, collection: true
13
- attribute :choice, Element, collection: true
7
+ attribute :attr_name, :string
8
+ attribute :name, Name
9
+ attribute :ns, :string
10
+ attribute :ns_name, NsName
11
+ attribute :datatypeLibrary, :string
12
+ attribute :id, :string
13
+ attribute :attribute, Attribute
14
+ attribute :ref, Ref, collection: true
15
+ attribute :choice, Choice
16
+ attribute :group, Group
17
+ attribute :interleave, Interleave
18
+ attribute :mixed, Mixed
19
+ attribute :optional, Optional
20
+ attribute :zeroOrMore, ZeroOrMore
21
+ attribute :oneOrMore, OneOrMore, collection: true
22
+ attribute :anyName, AnyName
23
+ attribute :text, Text
24
+ attribute :empty, Empty
25
+ attribute :value, Value
26
+ attribute :data, Data
27
+ attribute :list, List
28
+ attribute :notAllowed, NotAllowed
29
+ attribute :element, Element, collection: true
30
+ attribute :grammar, Grammar
31
+ attribute :parent_ref, ParentRef
32
+ attribute :external_ref, ExternalRef
14
33
 
15
34
  xml do
16
- map_attribute "name", to: :name
17
- map_element "attribute", to: :attributes
18
- map_element "element", to: :elements
19
- map_element "text", to: :text
20
- map_element "zeroOrMore", to: :zero_or_more
21
- map_element "oneOrMore", to: :one_or_more
22
- map_element "optional", to: :optional
35
+ root "element", ordered: true
36
+ namespace "http://relaxng.org/ns/structure/1.0"
37
+
38
+ map_attribute "name", to: :attr_name
39
+ map_attribute "ns", to: :ns, value_map: {
40
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
41
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
42
+ }
43
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
44
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
45
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
46
+ }
47
+ map_attribute "id", to: :id
48
+ map_element "name", to: :name
49
+ map_element "nsName", to: :ns_name
50
+ map_element "attribute", to: :attribute
51
+ map_element "ref", to: :ref
23
52
  map_element "choice", to: :choice
53
+ map_element "group", to: :group
54
+ map_element "interleave", to: :interleave
55
+ map_element "mixed", to: :mixed
56
+ map_element "optional", to: :optional
57
+ map_element "zeroOrMore", to: :zeroOrMore
58
+ map_element "oneOrMore", to: :oneOrMore
59
+ map_element "anyName", to: :anyName
60
+ map_element "text", to: :text
61
+ map_element "empty", to: :empty
62
+ map_element "value", to: :value
63
+ map_element "data", to: :data
64
+ map_element "list", to: :list
65
+ map_element "notAllowed", to: :notAllowed
66
+ map_element "element", to: :element
67
+ map_element "grammar", to: :grammar
68
+ map_element "parentRef", to: :parent_ref
69
+ map_element "externalRef", to: :external_ref
24
70
  end
25
71
  end
26
72
  end
data/lib/rng/empty.rb ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Empty < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+
11
+ xml do
12
+ root "empty", ordered: true
13
+ namespace "http://relaxng.org/ns/structure/1.0"
14
+
15
+ map_attribute "id", to: :id
16
+ map_attribute "ns", to: :ns, value_map: {
17
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
18
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
19
+ }
20
+ map_attribute "datatypeLibrary", to: :datatypeLibrary
21
+ end
22
+ end
23
+ end
data/lib/rng/except.rb ADDED
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Except < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :ns_name, NsName, collection: true
10
+ attribute :datatypeLibrary, :string
11
+ attribute :name, Name, collection: true
12
+ attribute :element, Element, collection: true, initialize_empty: true
13
+ attribute :attribute, Attribute, collection: true, initialize_empty: true
14
+ attribute :ref, Ref, collection: true, initialize_empty: true
15
+ attribute :choice, Choice, collection: true, initialize_empty: true
16
+ attribute :group, Group, collection: true, initialize_empty: true
17
+ attribute :interleave, Interleave, collection: true, initialize_empty: true
18
+ attribute :mixed, Mixed, collection: true, initialize_empty: true
19
+ attribute :optional, Optional, collection: true, initialize_empty: true
20
+ attribute :zeroOrMore, ZeroOrMore, collection: true, initialize_empty: true
21
+ attribute :oneOrMore, OneOrMore, collection: true, initialize_empty: true
22
+ attribute :text, Text, collection: true, initialize_empty: true
23
+ attribute :empty, Empty, collection: true, initialize_empty: true
24
+ attribute :value, Value, collection: true, initialize_empty: true
25
+ attribute :data, Data, collection: true, initialize_empty: true
26
+ attribute :list, List, collection: true, initialize_empty: true
27
+ attribute :notAllowed, NotAllowed, collection: true, initialize_empty: true
28
+
29
+ xml do
30
+ root "except", ordered: true
31
+ namespace "http://relaxng.org/ns/structure/1.0"
32
+
33
+ map_attribute "id", to: :id
34
+ map_attribute "ns", to: :ns, value_map: {
35
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
36
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
37
+ }
38
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
39
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
40
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
41
+ }
42
+ map_element "name", to: :name
43
+ map_element "element", to: :element
44
+ map_element "attribute", to: :attribute
45
+ map_element "ref", to: :ref
46
+ map_element "choice", to: :choice
47
+ map_element "group", to: :group
48
+ map_element "interleave", to: :interleave
49
+ map_element "mixed", to: :mixed
50
+ map_element "optional", to: :optional
51
+ map_element "zeroOrMore", to: :zeroOrMore
52
+ map_element "oneOrMore", to: :oneOrMore
53
+ map_element "text", to: :text
54
+ map_element "empty", to: :empty
55
+ map_element "value", to: :value
56
+ map_element "data", to: :data
57
+ map_element "list", to: :list
58
+ map_element "notAllowed", to: :notAllowed
59
+ map_element "nsName", to: :ns_name
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class ExternalRef < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+ attribute :href, :string
11
+
12
+ xml do
13
+ root "externalRef"
14
+ namespace "http://relaxng.org/ns/structure/1.0"
15
+
16
+ map_attribute "id", to: :id
17
+ map_attribute "ns", to: :ns, value_map: {
18
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
19
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
20
+ }
21
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
22
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
23
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
24
+ }
25
+ map_attribute "href", to: :href
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ # This represents the RNG schema
7
+ class Grammar < Lutaml::Model::Serializable
8
+ attribute :id, :string
9
+ attribute :ns, :string
10
+ attribute :datatypeLibrary, :string
11
+ attribute :start, Start, collection: true
12
+ attribute :define, Define, collection: true, initialize_empty: true
13
+ attribute :element, Element, collection: true
14
+ attribute :include, Include, collection: true
15
+
16
+ xml do
17
+ root "grammar", ordered: true
18
+ namespace "http://relaxng.org/ns/structure/1.0"
19
+
20
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
21
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
22
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
23
+ }
24
+ map_attribute "ns", to: :ns, value_map: {
25
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
26
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
27
+ }
28
+ map_attribute "id", to: :id
29
+
30
+ map_element "start", to: :start
31
+ map_element "define", to: :define
32
+ map_element "element", to: :element
33
+ map_element "include", to: :include
34
+ end
35
+ end
36
+ end
data/lib/rng/group.rb ADDED
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Group < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+ attribute :externalRef, ExternalRef
11
+ attribute :element, Element, collection: true, initialize_empty: true
12
+ attribute :attribute, Attribute, collection: true, initialize_empty: true
13
+ attribute :ref, Ref, collection: true, initialize_empty: true
14
+ attribute :choice, Choice, collection: true, initialize_empty: true
15
+ attribute :group, Group, collection: true, initialize_empty: true
16
+ attribute :interleave, Interleave, collection: true, initialize_empty: true
17
+ attribute :mixed, Mixed, collection: true, initialize_empty: true
18
+ attribute :optional, Optional, collection: true, initialize_empty: true
19
+ attribute :zeroOrMore, ZeroOrMore, collection: true, initialize_empty: true
20
+ attribute :oneOrMore, OneOrMore, collection: true, initialize_empty: true
21
+ attribute :text, Text, collection: true, initialize_empty: true
22
+ attribute :empty, Empty, collection: true, initialize_empty: true
23
+ attribute :value, Value, collection: true, initialize_empty: true
24
+ attribute :data, Data, collection: true, initialize_empty: true
25
+ attribute :list, List, collection: true, initialize_empty: true
26
+ attribute :notAllowed, NotAllowed, collection: true, initialize_empty: true
27
+
28
+ xml do
29
+ root "group", ordered: true
30
+ namespace "http://relaxng.org/ns/structure/1.0"
31
+
32
+ map_attribute "id", to: :id
33
+ map_attribute "ns", to: :ns, value_map: {
34
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
35
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
36
+ }
37
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
38
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
39
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
40
+ }
41
+ map_element "element", to: :element
42
+ map_element "attribute", to: :attribute
43
+ map_element "ref", to: :ref
44
+ map_element "choice", to: :choice
45
+ map_element "group", to: :group
46
+ map_element "interleave", to: :interleave
47
+ map_element "mixed", to: :mixed
48
+ map_element "optional", to: :optional
49
+ map_element "zeroOrMore", to: :zeroOrMore
50
+ map_element "oneOrMore", to: :oneOrMore
51
+ map_element "text", to: :text
52
+ map_element "empty", to: :empty
53
+ map_element "value", to: :value
54
+ map_element "data", to: :data
55
+ map_element "list", to: :list
56
+ map_element "notAllowed", to: :notAllowed
57
+ map_element "externalRef", to: :externalRef
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Include < Lutaml::Model::Serializable
7
+ attribute :href, :string
8
+ attribute :ns, :string
9
+ attribute :define, Define
10
+ attribute :grammar, Grammar
11
+
12
+ xml do
13
+ root "include"
14
+
15
+ map_attribute "href", to: :href
16
+ map_attribute "ns", to: :ns, value_map: {
17
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
18
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
19
+ }
20
+ map_content to: :grammar
21
+ map_element "define", to: :define
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class Interleave < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+ attribute :element, Element, collection: true, initialize_empty: true
11
+ attribute :attribute, Attribute, collection: true, initialize_empty: true
12
+ attribute :ref, Ref, collection: true, initialize_empty: true
13
+ attribute :choice, Choice, collection: true, initialize_empty: true
14
+ attribute :group, Group, collection: true, initialize_empty: true
15
+ attribute :interleave, Interleave, collection: true, initialize_empty: true
16
+ attribute :mixed, Mixed, collection: true, initialize_empty: true
17
+ attribute :optional, Optional, collection: true, initialize_empty: true
18
+ attribute :zeroOrMore, ZeroOrMore, collection: true, initialize_empty: true
19
+ attribute :oneOrMore, OneOrMore, collection: true, initialize_empty: true
20
+ attribute :text, Text, collection: true, initialize_empty: true
21
+ attribute :empty, Empty, collection: true, initialize_empty: true
22
+ attribute :value, Value, collection: true, initialize_empty: true
23
+ attribute :data, Data, collection: true, initialize_empty: true
24
+ attribute :list, List, collection: true, initialize_empty: true
25
+ attribute :notAllowed, NotAllowed, collection: true, initialize_empty: true
26
+
27
+ xml do
28
+ root "interleave", ordered: true
29
+ namespace "http://relaxng.org/ns/structure/1.0"
30
+
31
+ map_attribute "id", to: :id
32
+ map_attribute "ns", to: :ns, value_map: {
33
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
34
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
35
+ }
36
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
37
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
38
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
39
+ }
40
+ map_element "element", to: :element
41
+ map_element "attribute", to: :attribute
42
+ map_element "ref", to: :ref
43
+ map_element "choice", to: :choice
44
+ map_element "group", to: :group
45
+ map_element "interleave", to: :interleave
46
+ map_element "mixed", to: :mixed
47
+ map_element "optional", to: :optional
48
+ map_element "zeroOrMore", to: :zeroOrMore
49
+ map_element "oneOrMore", to: :oneOrMore
50
+ map_element "text", to: :text
51
+ map_element "empty", to: :empty
52
+ map_element "value", to: :value
53
+ map_element "data", to: :data
54
+ map_element "list", to: :list
55
+ map_element "notAllowed", to: :notAllowed
56
+ end
57
+ end
58
+ end
data/lib/rng/list.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Rng
6
+ class List < Lutaml::Model::Serializable
7
+ attribute :id, :string
8
+ attribute :ns, :string
9
+ attribute :datatypeLibrary, :string
10
+ attribute :element, Element, collection: true, initialize_empty: true
11
+ attribute :attribute, Attribute, collection: true, initialize_empty: true
12
+ attribute :ref, Ref, collection: true, initialize_empty: true
13
+ attribute :choice, Choice, collection: true, initialize_empty: true
14
+ attribute :group, Group, collection: true, initialize_empty: true
15
+ attribute :interleave, Interleave, collection: true, initialize_empty: true
16
+ attribute :mixed, Mixed, collection: true, initialize_empty: true
17
+ attribute :optional, Optional, collection: true, initialize_empty: true
18
+ attribute :zeroOrMore, ZeroOrMore, collection: true, initialize_empty: true
19
+ attribute :oneOrMore, OneOrMore, collection: true, initialize_empty: true
20
+ attribute :text, Text, collection: true, initialize_empty: true
21
+ attribute :empty, Empty, collection: true, initialize_empty: true
22
+ attribute :value, Value, collection: true, initialize_empty: true
23
+ attribute :data, Data, collection: true, initialize_empty: true
24
+ attribute :notAllowed, NotAllowed, collection: true, initialize_empty: true
25
+
26
+ xml do
27
+ root "list", ordered: true
28
+ namespace "http://relaxng.org/ns/structure/1.0"
29
+
30
+ map_attribute "id", to: :id
31
+ map_attribute "ns", to: :ns, value_map: {
32
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
33
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
34
+ }
35
+ map_attribute "datatypeLibrary", to: :datatypeLibrary, value_map: {
36
+ from: { empty: :empty, omitted: :omitted, nil: :nil },
37
+ to: { empty: :empty, omitted: :omitted, nil: :nil }
38
+ }
39
+ map_element "element", to: :element
40
+ map_element "attribute", to: :attribute
41
+ map_element "ref", to: :ref
42
+ map_element "choice", to: :choice
43
+ map_element "group", to: :group
44
+ map_element "interleave", to: :interleave
45
+ map_element "mixed", to: :mixed
46
+ map_element "optional", to: :optional
47
+ map_element "zeroOrMore", to: :zeroOrMore
48
+ map_element "oneOrMore", to: :oneOrMore
49
+ map_element "text", to: :text
50
+ map_element "empty", to: :empty
51
+ map_element "value", to: :value
52
+ map_element "data", to: :data
53
+ map_element "notAllowed", to: :notAllowed
54
+ end
55
+ end
56
+ end