lutaml-xsd 0.1.0 → 1.0.0

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE.md +33 -0
  5. data/README.adoc +141 -0
  6. data/lib/lutaml/xsd/all.rb +24 -0
  7. data/lib/lutaml/xsd/annotation.rb +20 -0
  8. data/lib/lutaml/xsd/any.rb +26 -0
  9. data/lib/lutaml/xsd/any_attribute.rb +22 -0
  10. data/lib/lutaml/xsd/appinfo.rb +18 -0
  11. data/lib/lutaml/xsd/attribute.rb +34 -0
  12. data/lib/lutaml/xsd/attribute_group.rb +28 -0
  13. data/lib/lutaml/xsd/choice.rb +35 -0
  14. data/lib/lutaml/xsd/complex_content.rb +26 -0
  15. data/lib/lutaml/xsd/complex_type.rb +44 -0
  16. data/lib/lutaml/xsd/documentation.rb +20 -0
  17. data/lib/lutaml/xsd/element.rb +54 -0
  18. data/lib/lutaml/xsd/enumeration.rb +18 -0
  19. data/lib/lutaml/xsd/extension_complex_content.rb +34 -0
  20. data/lib/lutaml/xsd/extension_simple_content.rb +26 -0
  21. data/lib/lutaml/xsd/field.rb +18 -0
  22. data/lib/lutaml/xsd/fraction_digits.rb +22 -0
  23. data/lib/lutaml/xsd/glob.rb +63 -0
  24. data/lib/lutaml/xsd/group.rb +35 -0
  25. data/lib/lutaml/xsd/import.rb +26 -0
  26. data/lib/lutaml/xsd/include.rb +24 -0
  27. data/lib/lutaml/xsd/key.rb +25 -0
  28. data/lib/lutaml/xsd/keyref.rb +26 -0
  29. data/lib/lutaml/xsd/length.rb +20 -0
  30. data/lib/lutaml/xsd/list.rb +21 -0
  31. data/lib/lutaml/xsd/max_exclusive.rb +18 -0
  32. data/lib/lutaml/xsd/max_inclusive.rb +16 -0
  33. data/lib/lutaml/xsd/max_length.rb +18 -0
  34. data/lib/lutaml/xsd/min_exclusive.rb +18 -0
  35. data/lib/lutaml/xsd/min_inclusive.rb +16 -0
  36. data/lib/lutaml/xsd/min_length.rb +18 -0
  37. data/lib/lutaml/xsd/notation.rb +24 -0
  38. data/lib/lutaml/xsd/pattern.rb +18 -0
  39. data/lib/lutaml/xsd/redefine.rb +28 -0
  40. data/lib/lutaml/xsd/restriction_complex_content.rb +34 -0
  41. data/lib/lutaml/xsd/restriction_simple_content.rb +52 -0
  42. data/lib/lutaml/xsd/restriction_simple_type.rb +46 -0
  43. data/lib/lutaml/xsd/schema.rb +176 -0
  44. data/lib/lutaml/xsd/selector.rb +20 -0
  45. data/lib/lutaml/xsd/sequence.rb +34 -0
  46. data/lib/lutaml/xsd/simple_content.rb +24 -0
  47. data/lib/lutaml/xsd/simple_type.rb +28 -0
  48. data/lib/lutaml/xsd/total_digits.rb +22 -0
  49. data/lib/lutaml/xsd/union.rb +22 -0
  50. data/lib/lutaml/xsd/unique.rb +24 -0
  51. data/lib/lutaml/xsd/version.rb +1 -1
  52. data/lib/lutaml/xsd/white_space.rb +20 -0
  53. data/lib/lutaml/xsd/xsd.rb +16 -0
  54. data/lib/lutaml/xsd.rb +9 -7
  55. data/lutaml-xsd.gemspec +3 -0
  56. metadata +84 -9
  57. data/LICENSE.txt +0 -21
  58. data/README.md +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85cb4cbd82c07c758dcc239a61c3a6d302ae093e407862a5429090e11af6e266
4
- data.tar.gz: 3fb08c6d788f5ae48022d088412fd7c084c680ec49276289b65e5b1654bf8072
3
+ metadata.gz: a4296cdc53ac951e9dabd94e87350ea4d82e7691fcd879e5ea38d9ac619c620e
4
+ data.tar.gz: a9e1191c508dabc0bc942e86b210f06d4c27815ab10cf5fbdc322bbde0b59f68
5
5
  SHA512:
6
- metadata.gz: 5d186b892aaa8b12959bf93f5eb8cd587301cabb7c7dd6dd72d93a2faa2df126bdf7086e2b66f012ced853f7998502f07b9869c2cb73b904869ae1d9685ea0fa
7
- data.tar.gz: 165670c5135e86c953ca6a3a40812f31b1acaaa3155eb221e022531192cdb24ca938834ab94d39c58c5093742eb0c12c198f46696b4017a8443ca84923c63d1a
6
+ metadata.gz: 2d69274700a75e1756c82103c095a0bf3b5b56fb0c9d9c35da98112afcbca422e37cfed00d46579f0969fec4392ae04b993f57e58f1aaea35e513d6ae39577ff
7
+ data.tar.gz: 7ffa3d40825726c740a29cac23685e32aff7f4295603634361524305b7579bbf4b02194582b78f12da42c6923657c682b7182d863b08bbd9267ce3190bef6149
data/.rubocop.yml CHANGED
@@ -6,3 +6,6 @@ Style/StringLiterals:
6
6
 
7
7
  Style/StringLiteralsInInterpolation:
8
8
  EnforcedStyle: double_quotes
9
+
10
+ Documentation:
11
+ Enabled: false
data/Gemfile CHANGED
@@ -5,8 +5,14 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in lutaml-xsd.gemspec
6
6
  gemspec
7
7
 
8
+ gem "equivalent-xml"
9
+
8
10
  gem "rake", "~> 13.0"
9
11
 
10
12
  gem "rspec", "~> 3.0"
11
13
 
12
14
  gem "rubocop", "~> 1.21"
15
+
16
+ gem "nokogiri"
17
+
18
+ gem "xml-c14n"
data/LICENSE.md ADDED
@@ -0,0 +1,33 @@
1
+ Licenses & Copyright
2
+ ====================
3
+
4
+ This license file adheres to the formatting guidelines of
5
+ [readable-licenses](https://github.com/nevir/readable-licenses).
6
+
7
+
8
+ Ribose's BSD 2-Clause License
9
+ -----------------------------
10
+
11
+ Copyright (c) 2024, [Ribose Inc](https://www.ribose.com).
12
+ All rights reserved.
13
+
14
+ Redistribution and use in source and binary forms, with or without modification,
15
+ are permitted provided that the following conditions are met:
16
+
17
+ 1. Redistributions of source code must retain the above copyright notice,
18
+ this list of conditions and the following disclaimer.
19
+
20
+ 2. Redistributions in binary form must reproduce the above copyright notice,
21
+ this list of conditions and the following disclaimer in the documentation
22
+ and/or other materials provided with the distribution.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc ADDED
@@ -0,0 +1,141 @@
1
+ = Lutaml::Xsd
2
+
3
+ == Overview
4
+
5
+ **Lutaml::Xsd** is a *Ruby* gem designed to parse and build *XML Schema Definition (XSD)* objects. It provides a robust framework for handling *XSD* *elements*, *attributes*, and *complex types*, allowing users to manipulate and generate *XSD* objects programmatically.
6
+
7
+ == Installation
8
+
9
+ To install *Lutaml::Xsd*, add this line to your application's Gemfile:
10
+
11
+ [source,ruby]
12
+ ----
13
+ gem 'lutaml-xsd'
14
+ ----
15
+
16
+ And then execute:
17
+
18
+ [source,bash]
19
+ ----
20
+ bundle install
21
+ ----
22
+
23
+ Or install it by running:
24
+
25
+ [source,bash]
26
+ ----
27
+ gem install lutaml-xsd
28
+ ----
29
+
30
+ == Usage
31
+
32
+ === Parsing XSD Files
33
+
34
+ To parse an *XSD* file, you can use the `Lutaml::Xsd.parse` method. This method takes the content of an *XSD* file as a string and optional parameters such as the location of the *XSD* file for resolving relative paths.
35
+
36
+ [source,ruby]
37
+ ----
38
+ require 'lutaml/xsd'
39
+
40
+ xsd_content = File.read('path/to/your/schema.xsd')
41
+ parsed_schema = Lutaml::Xsd.parse(xsd_content, location: 'path/to/your/')
42
+ ----
43
+
44
+ === Working with Parsed Data
45
+
46
+ Once parsed, the data is represented as instances of various classes such as `Lutaml::Xsd::Schema`, `Lutaml::Xsd::Element`, and others. These objects reflect the structure of the *XSD* and can be manipulated or inspected in *Ruby*.
47
+
48
+ [source,ruby]
49
+ ----
50
+ schema = <<~SCHEMA
51
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
52
+ <xsd:element name="root">
53
+ ...
54
+ </xsd:element>
55
+ <xsd:element name="root1">
56
+ ...
57
+ </xsd:element>
58
+ </xsd:schema>
59
+ SCHEMA
60
+
61
+ parsed_schema = Lutaml::Xsd.parse(schema, location: 'http://example.com/')
62
+
63
+ # Accessing elements of the schema
64
+ elements = parsed_schema.element
65
+ elements.each do |element|
66
+ puts "Element Name: #{element.name}"
67
+ end
68
+ # the output will be:
69
+ > Element Name: root
70
+ > Element Name: root1
71
+ ----
72
+
73
+ === Serialization
74
+
75
+ The gem supports serializing the schema back to *XML*. Each class like `Lutaml::Xsd::Schema` has a method `to_xml` that generates the *XML* representation of the object.
76
+
77
+ [source,ruby]
78
+ ----
79
+ xml_output = parsed_schema.to_xml
80
+ puts xml_output
81
+ ----
82
+
83
+ == Key Components
84
+
85
+ === Schema Representation
86
+
87
+ The *Lutaml::Xsd::Schema* class represents an *XSD* schema. It includes attributes for various schema properties like target namespace, element form default, and others.
88
+
89
+ - **Attributes and Elements**: The schema object contains collections of elements, complex types, simple types, etc., which are all accessible via attributes on the `Schema` object.
90
+
91
+ === Include and Import Handling
92
+
93
+ The path provided in `location` via `Lutaml::Xsd.parse(schema, location: 'path/to/your/directory/')` is used for resolving relative paths provided in *include* and *import* element's *schemaLocation* attribute.
94
+
95
+ Make sure to provide the directory *path*/*URL* in `location` parameter, as it will be used as base path for resolving relative paths.
96
+
97
+ For example, if *URL* is provided:
98
+
99
+ [source,ruby]
100
+ ----
101
+ Lutaml::Xsd.parse(xsd_content, location: 'http://example.com/directory/')
102
+ ----
103
+
104
+ If local path is provided:
105
+
106
+ [source,ruby]
107
+ ----
108
+ Lutaml::Xsd.parse(xsd_content, location: 'path/to/your/directory/')
109
+ ----
110
+
111
+ [source, xml]
112
+ ----
113
+ <xs:include schemaLocation="<location>/directory2/metaschema.xsd"/>
114
+ <!-- AND/OR -->
115
+ <xs:import schemaLocation="<location>/metaschema.xsd"/>
116
+ ----
117
+
118
+ All schemas specified in the *include* and/or *import* elements will be fetched from their *schemaLocation*, parsed and added to their parent *Lutaml::Xsd::Schema* object.
119
+
120
+ == Development
121
+
122
+ - **Dependencies**: The gem depends on other gems like `zeitwerk` for autoloading and `lutaml-model` for model serialization. See the `Gemfile` and `lutaml-xsd.gemspec` for details on dependencies.
123
+
124
+ - **Testing**: Tests are written using RSpec. Test files and fixtures are located in the `spec` directory.
125
+
126
+ == About LutaML
127
+
128
+ The name "LutaML" is pronounced as "Looh-tah-mel".
129
+
130
+ The name "LutaML" comes from the Latin word for clay, "Lutum", and "ML"
131
+ for "Markup Language". Just as clay can be molded and modeled into beautiful and
132
+ practical end products, the Lutaml::Model gem is used for data modeling,
133
+ allowing you to shape and structure your data into useful forms.
134
+
135
+
136
+ == License and Copyright
137
+
138
+ This project is licensed under the BSD 2-clause License.
139
+ See the link:LICENSE.md[] file for details.
140
+
141
+ Copyright Ribose.
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class All < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :max_occurs, :string
8
+ attribute :min_occurs, :string
9
+ attribute :annotation, Annotation
10
+ attribute :element, Element, collection: true
11
+
12
+ xml do
13
+ root "all", mixed: true
14
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
15
+
16
+ map_attribute :id, to: :id
17
+ map_attribute :max_occurs, to: :max_occurs
18
+ map_attribute :min_occurs, to: :min_occurs
19
+ map_element :annotation, to: :annotation
20
+ map_element :element, to: :element
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Annotation < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :documentation, Documentation, collection: true
8
+ attribute :appinfo, Appinfo, collection: true
9
+
10
+ xml do
11
+ root "annotation", mixed: true
12
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
13
+
14
+ map_attribute :id, to: :id
15
+ map_element :documentation, to: :documentation
16
+ map_element :appinfo, to: :appinfo
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Any < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :min_occurs, :string
8
+ attribute :max_occurs, :string
9
+ attribute :namespace, :string
10
+ attribute :process_contents, :string
11
+ attribute :annotation, Annotation
12
+
13
+ xml do
14
+ root "any", mixed: true
15
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
16
+
17
+ map_attribute :id, to: :id
18
+ map_attribute :namespace, to: :namespace
19
+ map_attribute :minOccurs, to: :min_occurs
20
+ map_attribute :maxOccurs, to: :max_occurs
21
+ map_attribute :processContents, to: :process_contents
22
+ map_element :annotation, to: :annotation
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class AnyAttribute < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :namespace, :string
8
+ attribute :process_contents, :string
9
+ attribute :annotation, Annotation
10
+
11
+ xml do
12
+ root "anyAttribute", mixed: true
13
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
14
+
15
+ map_attribute :id, to: :id
16
+ map_attribute :namespace, to: :namespace
17
+ map_attribute :processContents, to: :process_contents
18
+ map_element :annotation, to: :annotation
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Appinfo < Model::Serializable
6
+ attribute :source, :string
7
+ attribute :text, :string
8
+
9
+ xml do
10
+ root "appinfo", mixed: true
11
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
12
+
13
+ map_content to: :text
14
+ map_attribute :source, to: :source
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Attribute < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :use, :string, values: %w[required prohibited optional], default: -> { "optional" }
8
+ attribute :ref, :string
9
+ attribute :name, :string
10
+ attribute :type, :string
11
+ attribute :form, :string
12
+ attribute :fixed, :string
13
+ attribute :default, :string
14
+ attribute :annotation, Annotation
15
+ attribute :simple_type, SimpleType
16
+
17
+ xml do
18
+ root "attribute", mixed: true
19
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
20
+
21
+ map_attribute :id, to: :id
22
+ map_attribute :use, to: :use
23
+ map_attribute :ref, to: :ref
24
+ map_attribute :name, to: :name
25
+ map_attribute :type, to: :type
26
+ map_attribute :form, to: :form
27
+ map_attribute :fixed, to: :fixed
28
+ map_attribute :default, to: :default
29
+ map_element :annotation, to: :annotation
30
+ map_element :simpleType, to: :simple_type
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class AttributeGroup < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :name, :string
8
+ attribute :ref, :string
9
+ attribute :annotation, Annotation
10
+ attribute :any_attribute, AnyAttribute
11
+ attribute :attribute, Attribute, collection: true
12
+ attribute :attribute_group, AttributeGroup, collection: true
13
+
14
+ xml do
15
+ root "attributeGroup", mixed: true
16
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
17
+
18
+ map_attribute :id, to: :id
19
+ map_attribute :ref, to: :ref
20
+ map_attribute :name, to: :name
21
+ map_element :attribute, to: :attribute
22
+ map_element :annotation, to: :annotation
23
+ map_element :anyAttribute, to: :any_attribute
24
+ map_element :attributeGroup, to: :attribute_group
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Sequence < Model::Serializable; end
6
+ class Group < Model::Serializable; end
7
+
8
+ class Choice < Model::Serializable
9
+ attribute :id, :string
10
+ attribute :min_occurs, :string
11
+ attribute :max_occurs, :string
12
+ attribute :annotation, Annotation
13
+ attribute :any, Any, collection: true
14
+ attribute :group, Group, collection: true
15
+ attribute :choice, Choice, collection: true
16
+ attribute :element, Element, collection: true
17
+ attribute :sequence, Sequence, collection: true
18
+
19
+ xml do
20
+ root "choice", mixed: true
21
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
22
+
23
+ map_attribute :id, to: :id
24
+ map_attribute :minOccurs, to: :min_occurs
25
+ map_attribute :maxOccurs, to: :max_occurs
26
+ map_element :annotation, to: :annotation
27
+ map_element :sequence, to: :sequence
28
+ map_element :element, to: :element
29
+ map_element :choice, to: :choice
30
+ map_element :group, to: :group
31
+ map_element :any, to: :any
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class ExtensionComplexContent < Model::Serializable; end
6
+
7
+ class ComplexContent < Model::Serializable
8
+ attribute :id, :string
9
+ attribute :mixed, :boolean
10
+ attribute :extension, ExtensionComplexContent
11
+ attribute :annotation, Annotation
12
+ attribute :restriction, RestrictionComplexContent
13
+
14
+ xml do
15
+ root "complexContent", mixed: true
16
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
17
+
18
+ map_attribute :id, to: :id
19
+ map_attribute :mixed, to: :mixed
20
+ map_element :extension, to: :extension
21
+ map_element :annotation, to: :annotation
22
+ map_element :restriction, to: :restriction
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class ComplexType < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :name, :string
8
+ attribute :final, :string
9
+ attribute :block, :string
10
+ attribute :mixed, :boolean, default: -> { false }
11
+ attribute :abstract, :boolean, default: -> { false }
12
+ attribute :all, All
13
+ attribute :group, Group
14
+ attribute :choice, Choice
15
+ attribute :sequence, Sequence
16
+ attribute :annotation, Annotation
17
+ attribute :simple_content, SimpleContent
18
+ attribute :complex_content, ComplexContent
19
+ attribute :attribute, Attribute, collection: true
20
+ attribute :attribute_group, AttributeGroup, collection: true
21
+
22
+ xml do
23
+ root "complexType", mixed: true
24
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
25
+
26
+ map_attribute :id, to: :id
27
+ map_attribute :name, to: :name
28
+ map_attribute :final, to: :final
29
+ map_attribute :block, to: :block
30
+ map_attribute :mixed, to: :mixed
31
+ map_attribute :abstract, to: :abstract
32
+ map_element :all, to: :all
33
+ map_element :group, to: :group
34
+ map_element :choice, to: :choice
35
+ map_element :sequence, to: :sequence
36
+ map_element :attribute, to: :attribute
37
+ map_element :annotation, to: :annotation
38
+ map_element :attributeGroup, to: :attribute_group
39
+ map_element :simpleContent, to: :simple_content
40
+ map_element :complexContent, to: :complex_content
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Documentation < Model::Serializable
6
+ attribute :lang, :string
7
+ attribute :source, :string
8
+ attribute :content, :string
9
+
10
+ xml do
11
+ root "documentation"
12
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
13
+
14
+ map_all to: :content
15
+ map_attribute :lang, to: :lang
16
+ map_attribute :source, to: :source
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Element < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :ref, :string
8
+ attribute :name, :string
9
+ attribute :type, :string
10
+ attribute :form, :string
11
+ attribute :block, :string
12
+ attribute :final, :string
13
+ attribute :fixed, :string
14
+ attribute :default, :string
15
+ attribute :nillable, :string
16
+ attribute :abstract, :boolean, default: -> { false }
17
+ attribute :min_occurs, :string
18
+ attribute :max_occurs, :string
19
+ attribute :substitution_group, :string
20
+ attribute :annotation, Annotation
21
+ attribute :simple_type, SimpleType
22
+ attribute :complex_type, ComplexType
23
+ attribute :key, Key, collection: true
24
+ attribute :keyref, Keyref, collection: true
25
+ attribute :unique, Unique, collection: true
26
+
27
+ xml do
28
+ root "element", mixed: true
29
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
30
+
31
+ map_attribute :id, to: :id
32
+ map_attribute :ref, to: :ref
33
+ map_attribute :name, to: :name
34
+ map_attribute :type, to: :type
35
+ map_attribute :form, to: :form
36
+ map_attribute :block, to: :block
37
+ map_attribute :final, to: :final
38
+ map_attribute :fixed, to: :fixed
39
+ map_attribute :default, to: :default
40
+ map_attribute :nillable, to: :nillable
41
+ map_attribute :abstract, to: :abstract
42
+ map_attribute :minOccurs, to: :min_occurs
43
+ map_attribute :maxOccurs, to: :max_occurs
44
+ map_attribute :substitutionGroup, to: :substitution_group
45
+ map_element :complexType, to: :complex_type
46
+ map_element :simpleType, to: :simple_type
47
+ map_element :annotation, to: :annotation
48
+ map_element :keyref, to: :keyref
49
+ map_element :unique, to: :unique
50
+ map_element :key, to: :key
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Enumeration < Model::Serializable
6
+ attribute :value, :string
7
+ attribute :annotation, Annotation
8
+
9
+ xml do
10
+ root "enumeration", mixed: true
11
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
12
+
13
+ map_attribute :value, to: :value
14
+ map_element :annotation, to: :annotation
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class ExtensionComplexContent < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :base, :string
8
+ attribute :all, All
9
+ attribute :group, Group
10
+ attribute :choice, Choice
11
+ attribute :sequence, Sequence
12
+ attribute :annotation, Annotation
13
+ attribute :any_attribute, AnyAttribute
14
+ attribute :attribute, Attribute, collection: true
15
+ attribute :attribute_group, AttributeGroup, collection: true
16
+
17
+ xml do
18
+ root "extension", mixed: true
19
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
20
+
21
+ map_attribute :id, to: :id
22
+ map_attribute :base, to: :base
23
+ map_element :all, to: :all
24
+ map_element :group, to: :group
25
+ map_element :choice, to: :choice
26
+ map_element :sequence, to: :sequence
27
+ map_element :attribute, to: :attribute
28
+ map_element :annotation, to: :annotation
29
+ map_element :any_attribute, to: :any_attribute
30
+ map_element :attributeGroup, to: :attribute_group
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class ExtensionSimpleContent < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :base, :string
8
+ attribute :annotation, Annotation
9
+ attribute :any_attribute, AnyAttribute
10
+ attribute :attribute, Attribute, collection: true
11
+ attribute :attribute_group, AttributeGroup, collection: true
12
+
13
+ xml do
14
+ root "extension", mixed: true
15
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
16
+
17
+ map_attribute :id, to: :id
18
+ map_attribute :base, to: :base
19
+ map_element :attribute, to: :attribute
20
+ map_element :annotation, to: :annotation
21
+ map_element :any_attribute, to: :any_attribute
22
+ map_element :attributeGroup, to: :attribute_group
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Xsd
5
+ class Field < Model::Serializable
6
+ attribute :id, :string
7
+ attribute :xpath, :string
8
+
9
+ xml do
10
+ root "field", mixed: true
11
+ namespace "http://www.w3.org/2001/XMLSchema", "xsd"
12
+
13
+ map_attribute :id, to: :id
14
+ map_attribute :xpath, to: :xpath
15
+ end
16
+ end
17
+ end
18
+ end