xsd 1.0.0 → 2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +9 -0
- data/README.md +3 -2
- data/lib/xsd/base_object.rb +35 -35
- data/lib/xsd/generator.rb +7 -7
- data/lib/xsd/objects/all.rb +2 -2
- data/lib/xsd/objects/annotation.rb +2 -2
- data/lib/xsd/objects/any.rb +2 -2
- data/lib/xsd/objects/any_attribute.rb +2 -2
- data/lib/xsd/objects/appinfo.rb +1 -1
- data/lib/xsd/objects/attribute.rb +9 -9
- data/lib/xsd/objects/attribute_group.rb +1 -1
- data/lib/xsd/objects/choice.rb +4 -4
- data/lib/xsd/objects/complex_content.rb +3 -3
- data/lib/xsd/objects/complex_type.rb +12 -12
- data/lib/xsd/objects/documentation.rb +2 -2
- data/lib/xsd/objects/element.rb +19 -19
- data/lib/xsd/objects/facet.rb +1 -1
- data/lib/xsd/objects/field.rb +1 -1
- data/lib/xsd/objects/group.rb +4 -4
- data/lib/xsd/objects/import.rb +15 -44
- data/lib/xsd/objects/key.rb +3 -3
- data/lib/xsd/objects/keyref.rb +4 -4
- data/lib/xsd/objects/list.rb +1 -1
- data/lib/xsd/objects/restriction.rb +3 -3
- data/lib/xsd/objects/schema.rb +31 -31
- data/lib/xsd/objects/selector.rb +1 -1
- data/lib/xsd/objects/sequence.rb +4 -4
- data/lib/xsd/objects/simple_content.rb +2 -2
- data/lib/xsd/objects/simple_type.rb +5 -5
- data/lib/xsd/objects/union.rb +2 -2
- data/lib/xsd/objects/unique.rb +2 -2
- data/lib/xsd/shared/attribute_container.rb +2 -2
- data/lib/xsd/shared/based.rb +9 -9
- data/lib/xsd/shared/complex_typed.rb +7 -7
- data/lib/xsd/shared/element_container.rb +1 -1
- data/lib/xsd/shared/min_max_occurs.rb +4 -4
- data/lib/xsd/shared/referenced.rb +3 -3
- data/lib/xsd/shared/simple_typed.rb +1 -1
- data/lib/xsd/validator.rb +1 -1
- data/lib/xsd/version.rb +1 -1
- data/lib/xsd/xml.rb +102 -31
- data/xsd.gemspec +0 -8
- metadata +2 -100
data/lib/xsd/objects/element.rb
CHANGED
@@ -14,30 +14,30 @@ module XSD
|
|
14
14
|
|
15
15
|
# Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present
|
16
16
|
# @!attribute name
|
17
|
-
# @return
|
17
|
+
# @return String
|
18
18
|
property :name, :string
|
19
19
|
|
20
20
|
# Optional. Specifies either the name of a built-in data type, or the name of a simpleType or complexType element
|
21
21
|
# @!attribute type
|
22
|
-
# @return
|
22
|
+
# @return String, nil
|
23
23
|
property :type, :string
|
24
24
|
|
25
25
|
# Optional. Specifies the name of an element that can be substituted with this element. This attribute cannot be
|
26
26
|
# used if the parent element is not the schema element
|
27
27
|
# @!attribute substitution_group
|
28
|
-
# @return
|
28
|
+
# @return String, nil
|
29
29
|
property :substitutionGroup, :string
|
30
30
|
|
31
31
|
# Optional. Specifies a default value for the element (can only be used if the element's content is a simple type
|
32
32
|
# or text only)
|
33
33
|
# @!attribute default
|
34
|
-
# @return
|
34
|
+
# @return String, nil
|
35
35
|
property :default, :string
|
36
36
|
|
37
37
|
# Optional. Specifies a fixed value for the element (can only be used if the element's content is a simple type
|
38
38
|
# or text only)
|
39
39
|
# @!attribute fixed
|
40
|
-
# @return
|
40
|
+
# @return String, nil
|
41
41
|
property :fixed, :string
|
42
42
|
|
43
43
|
# Optional. Specifies the form for the element. "unqualified" indicates that this element is not required to be
|
@@ -45,21 +45,21 @@ module XSD
|
|
45
45
|
# prefix. The default value is the value of the elementFormDefault attribute of the schema element. This attribute
|
46
46
|
# cannot be used if the parent element is the schema element
|
47
47
|
# @!attribute form
|
48
|
-
# @return
|
48
|
+
# @return String
|
49
49
|
property :form, :string
|
50
50
|
|
51
51
|
# Optional. Specifies whether an explicit null value can be assigned to the element. True enables an instance of
|
52
52
|
# the element to have the null attribute set to true. The null attribute is defined as part of the XML Schema
|
53
53
|
# namespace for instances. Default is false
|
54
54
|
# @!attribute nillable
|
55
|
-
# @return
|
55
|
+
# @return Boolean
|
56
56
|
property :nillable, :boolean, default: false
|
57
57
|
|
58
58
|
# Optional. Specifies whether the element can be used in an instance document. True indicates that the element
|
59
59
|
# cannot appear in the instance document. Instead, another element whose substitutionGroup attribute contains the
|
60
60
|
# qualified name (QName) of this element must appear in this element's place. Default is false
|
61
61
|
# @!attribute abstract
|
62
|
-
# @return
|
62
|
+
# @return Boolean
|
63
63
|
property :abstract, :boolean, default: false
|
64
64
|
|
65
65
|
# Optional. Prevents an element with a specified type of derivation from being used in place of this element.
|
@@ -69,7 +69,7 @@ module XSD
|
|
69
69
|
# substitution - prevents elements derived by substitution
|
70
70
|
# #all - prevents all derived elements
|
71
71
|
# @!attribute block
|
72
|
-
# @return
|
72
|
+
# @return String, nil
|
73
73
|
property :block, :string
|
74
74
|
|
75
75
|
# Optional. Sets the default value of the final attribute on the element element. This attribute cannot be used if
|
@@ -79,50 +79,50 @@ module XSD
|
|
79
79
|
# restriction - prevents elements derived by restriction
|
80
80
|
# #all - prevents all derived elements
|
81
81
|
# @!attribute final
|
82
|
-
# @return
|
82
|
+
# @return String, nil
|
83
83
|
property :final, :string
|
84
84
|
|
85
85
|
# Nested unique objects
|
86
86
|
# @!attribute unique
|
87
|
-
# @return
|
87
|
+
# @return Array<Unique>
|
88
88
|
child :unique, [:unique]
|
89
89
|
|
90
90
|
# Determine if element is required
|
91
|
-
# @return
|
91
|
+
# @return Boolean
|
92
92
|
def required?
|
93
93
|
computed_min_occurs > 0
|
94
94
|
end
|
95
95
|
|
96
96
|
# Determine if element is optional
|
97
|
-
# @return
|
97
|
+
# @return Boolean
|
98
98
|
def optional?
|
99
99
|
!required?
|
100
100
|
end
|
101
101
|
|
102
102
|
# Determine if element may occur multiple times
|
103
|
-
# @return
|
103
|
+
# @return Boolean
|
104
104
|
def multiple_allowed?
|
105
105
|
computed_max_occurs == :unbounded || computed_max_occurs > 1
|
106
106
|
end
|
107
107
|
|
108
108
|
# Determine if element has complex content
|
109
|
-
# @return
|
109
|
+
# @return Boolean
|
110
110
|
def complex?
|
111
|
-
complex_type && !complex_type.simple_content &&
|
111
|
+
complex_type && !complex_type.simple_content && collect_elements.any?
|
112
112
|
end
|
113
113
|
|
114
114
|
# Get elements that can appear instead of this one
|
115
|
-
# @return
|
115
|
+
# @return Array<Element>
|
116
116
|
def substitution_elements
|
117
117
|
# TODO: for now we do not search in parent schemas (that imported current schema)
|
118
118
|
# TODO: refactor for better namespace handling (use xpath with namespaces or correct comparison)
|
119
|
-
schema.
|
119
|
+
schema.collect_elements.select do |element|
|
120
120
|
element.substitution_group&.split(':')&.last == name
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
# Get target namespace
|
125
|
-
# @return
|
125
|
+
# @return String
|
126
126
|
def target_namespace
|
127
127
|
schema.target_namespace
|
128
128
|
end
|
data/lib/xsd/objects/facet.rb
CHANGED
data/lib/xsd/objects/field.rb
CHANGED
data/lib/xsd/objects/group.rb
CHANGED
@@ -11,22 +11,22 @@ module XSD
|
|
11
11
|
|
12
12
|
# Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present
|
13
13
|
# @!attribute name
|
14
|
-
# @return
|
14
|
+
# @return String
|
15
15
|
property :name, :string
|
16
16
|
|
17
17
|
# Nested all object
|
18
18
|
# @!attribute all
|
19
|
-
# @return
|
19
|
+
# @return All
|
20
20
|
child :all, :all
|
21
21
|
|
22
22
|
# Nested choice object
|
23
23
|
# @!attribute choice
|
24
|
-
# @return
|
24
|
+
# @return Choice
|
25
25
|
child :choice, :choice
|
26
26
|
|
27
27
|
# Nested sequence object
|
28
28
|
# @!attribute sequence
|
29
|
-
# @return
|
29
|
+
# @return Sequence
|
30
30
|
child :sequence, :sequence
|
31
31
|
end
|
32
32
|
end
|
data/lib/xsd/objects/import.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rest-client'
|
4
|
-
|
5
3
|
module XSD
|
6
4
|
# The import element is used to add multiple schemas with different target namespace to a document.
|
7
5
|
# Parent elements: schema
|
@@ -9,59 +7,32 @@ module XSD
|
|
9
7
|
class Import < BaseObject
|
10
8
|
# Optional. Specifies the URI of the namespace to import
|
11
9
|
# @!attribute namespace
|
12
|
-
# @return
|
10
|
+
# @return String, nil
|
13
11
|
property :namespace, :string
|
14
12
|
|
15
13
|
# Optional. Specifies the URI to the schema for the imported namespace
|
16
14
|
# @!attribute schema_location
|
17
|
-
# @return
|
15
|
+
# @return String, nil
|
18
16
|
property :schemaLocation, :string
|
19
17
|
|
20
|
-
# Get imported
|
21
|
-
# @return
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
xml = if reader.imported_xsd[namespace]
|
26
|
-
# check in imported xsd by namespace
|
27
|
-
reader.imported_xsd[namespace]
|
28
|
-
elsif schema_location =~ /^https?:/
|
29
|
-
# check http(s) schema location
|
30
|
-
download_uri(schema_location)
|
31
|
-
elsif (path = local_path)
|
32
|
-
# check local relative path
|
33
|
-
path
|
34
|
-
elsif namespace =~ /^https?:/
|
35
|
-
# check http(s) namespace
|
36
|
-
# TODO: investigate spec conformance
|
37
|
-
download_uri(namespace.gsub(/#{File.basename(schema_location, '.*')}$/, '').to_s + schema_location)
|
38
|
-
else
|
39
|
-
raise ImportError, "Failed to locate import '#{schema_location}' for namespace '#{namespace}'"
|
40
|
-
end
|
41
|
-
|
42
|
-
# TODO: pass all provided options
|
43
|
-
@imported_reader = XSD::XML.new(xml, imported_xsd: reader.imported_xsd, logger: reader.logger)
|
44
|
-
end
|
45
|
-
|
46
|
-
def local_path
|
47
|
-
return unless reader.xsd.is_a?(Pathname)
|
48
|
-
|
49
|
-
path = reader.xsd.dirname.join(schema_location)
|
50
|
-
path.file? ? path : nil
|
51
|
-
end
|
18
|
+
# Get imported schema
|
19
|
+
# @return XSD:Schema
|
20
|
+
def imported_schema
|
21
|
+
schema = reader.schema_for_namespace(namespace)
|
22
|
+
return schema if schema
|
52
23
|
|
53
|
-
|
24
|
+
unless schema_location
|
25
|
+
raise ImportError, "Schema location not provided for namespace '#{namespace}', use add_schema_xml()/add_schema_node()"
|
26
|
+
end
|
54
27
|
|
55
|
-
|
56
|
-
reader.
|
28
|
+
xml = reader.resource_resolver.call(schema_location, namespace)
|
29
|
+
schema = reader.add_schema_xml(xml)
|
57
30
|
|
58
|
-
|
59
|
-
|
60
|
-
rescue RestClient::Exception => e
|
61
|
-
raise ImportError, e.message
|
31
|
+
unless namespace == schema.target_namespace
|
32
|
+
raise ImportError, 'Import location does not match imported schema targetNamespace'
|
62
33
|
end
|
63
34
|
|
64
|
-
|
35
|
+
schema
|
65
36
|
end
|
66
37
|
end
|
67
38
|
end
|
data/lib/xsd/objects/key.rb
CHANGED
@@ -9,17 +9,17 @@ module XSD
|
|
9
9
|
# The name must be a no-colon-name (NCName) as defined in the XML Namespaces specification.
|
10
10
|
# The name must be unique within an identity constraint set. Required.
|
11
11
|
# @!attribute name
|
12
|
-
# @return
|
12
|
+
# @return String
|
13
13
|
property :name, :string, required: true
|
14
14
|
|
15
15
|
# Get nested selector object
|
16
16
|
# @!attribute selector
|
17
|
-
# @return
|
17
|
+
# @return Selector
|
18
18
|
child :selector, :selector
|
19
19
|
|
20
20
|
# Get nested field objects
|
21
21
|
# @!attribute fields
|
22
|
-
# @return
|
22
|
+
# @return Array<Field>
|
23
23
|
child :fields, [:field]
|
24
24
|
end
|
25
25
|
end
|
data/lib/xsd/objects/keyref.rb
CHANGED
@@ -9,7 +9,7 @@ module XSD
|
|
9
9
|
# The name must be a no-colon-name (NCName) as defined in the XML Namespaces specification.
|
10
10
|
# The name must be unique within an identity constraint set. Required.
|
11
11
|
# @!attribute name
|
12
|
-
# @return
|
12
|
+
# @return String
|
13
13
|
property :name, :string, required: true
|
14
14
|
|
15
15
|
# The name of a key or unique element defined in this schema
|
@@ -17,17 +17,17 @@ module XSD
|
|
17
17
|
# The refer value must be a qualified name (QName).
|
18
18
|
# The type can include a namespace prefix. Required.
|
19
19
|
# @!attribute refer
|
20
|
-
# @return
|
20
|
+
# @return String
|
21
21
|
property :refer, :string, required: true
|
22
22
|
|
23
23
|
# Get nested selector object
|
24
24
|
# @!attribute selector
|
25
|
-
# @return
|
25
|
+
# @return Selector
|
26
26
|
child :selector, :selector
|
27
27
|
|
28
28
|
# Get nested field objects
|
29
29
|
# @!attribute fields
|
30
|
-
# @return
|
30
|
+
# @return Array<Field>
|
31
31
|
child :fields, [:field]
|
32
32
|
end
|
33
33
|
end
|
data/lib/xsd/objects/list.rb
CHANGED
@@ -12,7 +12,7 @@ module XSD
|
|
12
12
|
# Specifies the name of a built-in data type or simpleType element defined in this or another schema.
|
13
13
|
# This attribute is not allowed if the content contains a simpleType element, otherwise it is required
|
14
14
|
# @!attribute item_type
|
15
|
-
# @return
|
15
|
+
# @return String, nil
|
16
16
|
property :itemType, :string
|
17
17
|
end
|
18
18
|
end
|
@@ -17,7 +17,7 @@ module XSD
|
|
17
17
|
].freeze
|
18
18
|
|
19
19
|
# Get restriction facets
|
20
|
-
# @return
|
20
|
+
# @return Hash
|
21
21
|
def facets
|
22
22
|
nodes.inject({}) do |hash, node|
|
23
23
|
if FACET_ELEMENTS.include?(node.name)
|
@@ -40,8 +40,8 @@ module XSD
|
|
40
40
|
|
41
41
|
# Get all available elements on the current stack level, optionally including base type elements
|
42
42
|
# @param [Boolean] include_base
|
43
|
-
# @return
|
44
|
-
def
|
43
|
+
# @return Array<Element>
|
44
|
+
def collect_elements(include_base = false)
|
45
45
|
# By default we do not include base element for complex restrictions
|
46
46
|
super
|
47
47
|
end
|
data/lib/xsd/objects/schema.rb
CHANGED
@@ -13,7 +13,7 @@ module XSD
|
|
13
13
|
# are not required to be qualified with the namespace prefix. "qualified" indicates that attributes from the target
|
14
14
|
# namespace must be qualified with the namespace prefix
|
15
15
|
# @!attribute attribute_form_default
|
16
|
-
# @return
|
16
|
+
# @return String
|
17
17
|
property :attributeFormDefault, :string, default: 'unqualified'
|
18
18
|
|
19
19
|
# Optional. The form for elements declared in the target namespace of this schema. The value must be "qualified"
|
@@ -21,7 +21,7 @@ module XSD
|
|
21
21
|
# not required to be qualified with the namespace prefix. "qualified" indicates that elements from the target
|
22
22
|
# namespace must be qualified with the namespace prefix
|
23
23
|
# @!attribute element_form_default
|
24
|
-
# @return
|
24
|
+
# @return String
|
25
25
|
property :elementFormDefault, :string, default: 'unqualified'
|
26
26
|
|
27
27
|
# Optional. Specifies the default value of the block attribute on element and complexType elements in the target
|
@@ -33,7 +33,7 @@ module XSD
|
|
33
33
|
# substitution - prevents substitution of elements
|
34
34
|
# #all - prevents all derived complex types
|
35
35
|
# @!attribute block_default
|
36
|
-
# @return
|
36
|
+
# @return String
|
37
37
|
property :blockDefault, :string
|
38
38
|
|
39
39
|
# Optional. Specifies the default value of the final attribute on element, simpleType, and complexType elements in
|
@@ -46,109 +46,109 @@ module XSD
|
|
46
46
|
# union - prevents derivation by union
|
47
47
|
# #all - prevents all derivation
|
48
48
|
# @!attribute final_default
|
49
|
-
# @return
|
49
|
+
# @return String
|
50
50
|
property :finalDefault, :string
|
51
51
|
|
52
52
|
# Optional. A URI reference of the namespace of this schema
|
53
53
|
# @!attribute target_namespace
|
54
|
-
# @return
|
54
|
+
# @return String
|
55
55
|
property :targetNamespace, :string
|
56
56
|
|
57
57
|
# Optional. Specifies the version of the schema
|
58
58
|
# @!attribute version
|
59
|
-
# @return
|
59
|
+
# @return String
|
60
60
|
property :version, :string
|
61
61
|
|
62
62
|
# A URI reference that specifies one or more namespaces for use in this schema. If no prefix is assigned, the schema
|
63
63
|
# components of the namespace can be used with unqualified references
|
64
64
|
# @!attribute xmlns
|
65
|
-
# @return
|
65
|
+
# @return String
|
66
66
|
property :xmlns, :string
|
67
67
|
|
68
68
|
# Global complex types
|
69
69
|
# @!attribute complex_types
|
70
|
-
# @return
|
70
|
+
# @return Array<ComplexType>
|
71
71
|
child :complex_types, [:complexType]
|
72
72
|
|
73
73
|
# Global simple types
|
74
74
|
# @!attribute simple_types
|
75
|
-
# @return
|
75
|
+
# @return Array<SimpleType>
|
76
76
|
child :simple_types, [:simpleType]
|
77
77
|
|
78
78
|
# Global groups
|
79
79
|
# @!attribute groups
|
80
|
-
# @return
|
80
|
+
# @return Array<Group>
|
81
81
|
child :groups, [:group]
|
82
82
|
|
83
|
-
#
|
83
|
+
# Schema imports
|
84
84
|
# @!attribute imports
|
85
|
-
# @return
|
85
|
+
# @return Array<Import>
|
86
86
|
child :imports, [:import]
|
87
87
|
|
88
88
|
# Get current schema object
|
89
|
-
# @return
|
89
|
+
# @return Schema
|
90
90
|
def schema
|
91
91
|
self
|
92
92
|
end
|
93
93
|
|
94
|
-
# Get all available
|
95
|
-
# @return
|
96
|
-
def
|
94
|
+
# Get all available elements on the current stack level, for schema same as elements
|
95
|
+
# @return Array<Element>
|
96
|
+
def collect_elements(*)
|
97
97
|
elements
|
98
98
|
end
|
99
99
|
|
100
|
-
# Get all available
|
101
|
-
# @return
|
102
|
-
def
|
100
|
+
# Get all available attributes on the current stack level, for schema same as attributes
|
101
|
+
# @return Array<Attribute>
|
102
|
+
def collect_attributes(*)
|
103
103
|
attributes
|
104
104
|
end
|
105
105
|
|
106
106
|
# Get target namespace prefix. There may be more than one prefix, but we return only first defined
|
107
|
-
# @return
|
107
|
+
# @return String
|
108
108
|
def target_namespace_prefix
|
109
109
|
@target_namespace_prefix ||= namespaces.key(target_namespace)&.sub(/^xmlns:?/, '') || ''
|
110
110
|
end
|
111
111
|
|
112
112
|
# Get schema namespace prefix
|
113
|
-
# @return
|
113
|
+
# @return String
|
114
114
|
def namespace_prefix
|
115
115
|
@namespace_prefix ||= namespaces.key(XML_SCHEMA).sub(/^xmlns:?/, '')
|
116
116
|
end
|
117
117
|
|
118
118
|
# Check if namespace is a target namespace
|
119
|
-
# @param [String]
|
120
|
-
# @return
|
121
|
-
def targets_namespace?(
|
122
|
-
namespaces[
|
119
|
+
# @param [String] namespace
|
120
|
+
# @return Boolean
|
121
|
+
def targets_namespace?(namespace)
|
122
|
+
namespace == target_namespace || namespaces[namespace.empty? ? 'xmlns' : "xmlns:#{namespace}"] == target_namespace
|
123
123
|
end
|
124
124
|
|
125
125
|
# Override map_children on schema to get objects from all imported schemas
|
126
126
|
# @param [Symbol] name
|
127
|
-
# @return
|
127
|
+
# @return Array<BaseObject>
|
128
128
|
def map_children(name, cache = {})
|
129
129
|
super(name) + import_map_children(name, cache)
|
130
130
|
end
|
131
131
|
|
132
132
|
# Get children from all imported schemas
|
133
133
|
# @param [Symbol] name
|
134
|
-
# @return
|
135
|
-
# TODO: better recursion handling, may be refactor needed 1 reader for all schemas with centralized cache
|
134
|
+
# @return Array<BaseObject>
|
136
135
|
def import_map_children(name, cache)
|
137
136
|
return [] if name.to_sym == :import
|
138
137
|
|
139
138
|
imports.map do |import|
|
140
139
|
if cache[import.namespace]
|
141
|
-
reader.logger.debug(XSD) { "Schema '#{import.namespace}' already parsed, skiping" }
|
142
140
|
nil
|
143
141
|
else
|
144
142
|
cache[import.namespace] = true
|
145
|
-
import.
|
143
|
+
import.imported_schema.map_children(name, cache)
|
146
144
|
end
|
147
145
|
end.compact.flatten
|
148
146
|
end
|
149
147
|
|
148
|
+
# Get import by namespace
|
149
|
+
# @return Import
|
150
150
|
def import_by_namespace(ns)
|
151
|
-
aliases = [ns, namespaces["xmlns:#{(ns || '').gsub(/^xmlns:/, '')}"]].compact
|
151
|
+
aliases = [ns, namespaces["xmlns:#{(ns || '').gsub(/^xmlns:/, '')}"], reader.namespace_prefixes[ns]].compact
|
152
152
|
imports.find { |import| aliases.include?(import.namespace) }
|
153
153
|
end
|
154
154
|
end
|
data/lib/xsd/objects/selector.rb
CHANGED
@@ -9,7 +9,7 @@ module XSD
|
|
9
9
|
# Required. Specifies an XPath expression, relative to the element being declared, that identifies the child
|
10
10
|
# elements to which the identity constraint applies
|
11
11
|
# @!attribute xpath
|
12
|
-
# @return
|
12
|
+
# @return String
|
13
13
|
property :xpath, :string, required: true
|
14
14
|
end
|
15
15
|
end
|
data/lib/xsd/objects/sequence.rb
CHANGED
@@ -12,22 +12,22 @@ module XSD
|
|
12
12
|
|
13
13
|
# Nested groups
|
14
14
|
# @!attribute groups
|
15
|
-
# @return
|
15
|
+
# @return Array<Group>
|
16
16
|
child :groups, [:group]
|
17
17
|
|
18
18
|
# Nested choices
|
19
19
|
# @!attribute choices
|
20
|
-
# @return
|
20
|
+
# @return Array<Choice>
|
21
21
|
child :choices, [:choice]
|
22
22
|
|
23
23
|
# Nested sequences
|
24
24
|
# @!attribute sequences
|
25
|
-
# @return
|
25
|
+
# @return Array<Sequence>
|
26
26
|
child :sequences, [:sequence]
|
27
27
|
|
28
28
|
# Nested anys
|
29
29
|
# @!attribute anys
|
30
|
-
# @return
|
30
|
+
# @return Array<Any>
|
31
31
|
child :anys, [:any]
|
32
32
|
end
|
33
33
|
end
|
@@ -8,12 +8,12 @@ module XSD
|
|
8
8
|
class SimpleContent < BaseObject
|
9
9
|
# Nested extension
|
10
10
|
# @!attribute extension
|
11
|
-
# @return
|
11
|
+
# @return Extension, nil
|
12
12
|
child :extension, :extension
|
13
13
|
|
14
14
|
# Nested restriction
|
15
15
|
# @!attribute restriction
|
16
|
-
# @return
|
16
|
+
# @return Restriction, nil
|
17
17
|
child :restriction, :restriction
|
18
18
|
end
|
19
19
|
end
|
@@ -8,26 +8,26 @@ module XSD
|
|
8
8
|
class SimpleType < BaseObject
|
9
9
|
# Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present
|
10
10
|
# @!attribute name
|
11
|
-
# @return
|
11
|
+
# @return String
|
12
12
|
property :name, :string
|
13
13
|
|
14
14
|
# Nested restriction
|
15
15
|
# @!attribute restriction
|
16
|
-
# @return
|
16
|
+
# @return Restriction, nil
|
17
17
|
child :restriction, :restriction
|
18
18
|
|
19
19
|
# Nested union
|
20
20
|
# @!attribute union
|
21
|
-
# @return
|
21
|
+
# @return Union, nil
|
22
22
|
child :union, :union
|
23
23
|
|
24
24
|
# Nested list
|
25
25
|
# @!attribute list
|
26
|
-
# @return
|
26
|
+
# @return List, nil
|
27
27
|
child :list, :list
|
28
28
|
|
29
29
|
# Determine if this is a linked type
|
30
|
-
# @return
|
30
|
+
# @return Boolean
|
31
31
|
def linked?
|
32
32
|
!name.nil?
|
33
33
|
end
|
data/lib/xsd/objects/union.rb
CHANGED
@@ -7,13 +7,13 @@ module XSD
|
|
7
7
|
class Union < BaseObject
|
8
8
|
# Optional. Specifies a list of built-in data types or simpleType elements defined in a schema
|
9
9
|
# @!attribute member_types
|
10
|
-
# @return
|
10
|
+
# @return Array<String>
|
11
11
|
property :memberTypes, :array, default: [] do |union|
|
12
12
|
union.node['memberTypes']&.split(' ')
|
13
13
|
end
|
14
14
|
|
15
15
|
# Nested simple and built-in types
|
16
|
-
# @return
|
16
|
+
# @return Array<SimpleType, String>
|
17
17
|
def types
|
18
18
|
@types ||= map_children(:simpleType) + member_types.map do |name|
|
19
19
|
object_by_name(:simpleType, name) || name
|
data/lib/xsd/objects/unique.rb
CHANGED
@@ -7,12 +7,12 @@ module XSD
|
|
7
7
|
class Unique < BaseObject
|
8
8
|
# Get nested selector object
|
9
9
|
# @!attribute selector
|
10
|
-
# @return
|
10
|
+
# @return Selector
|
11
11
|
child :selector, :selector
|
12
12
|
|
13
13
|
# Get nested field objects
|
14
14
|
# @!attribute fields
|
15
|
-
# @return
|
15
|
+
# @return Array<Field>
|
16
16
|
child :fields, [:field]
|
17
17
|
end
|
18
18
|
end
|
@@ -4,11 +4,11 @@ module XSD
|
|
4
4
|
module AttributeContainer
|
5
5
|
# Nested attributes
|
6
6
|
# @!attribute attributes
|
7
|
-
# @return
|
7
|
+
# @return Array<Attribute>
|
8
8
|
|
9
9
|
# Nested attribute groups
|
10
10
|
# @!attribute attribute_groups
|
11
|
-
# @return
|
11
|
+
# @return Array<AttributeGroup>
|
12
12
|
def self.included(obj)
|
13
13
|
obj.child :attributes, [:attribute]
|
14
14
|
obj.child :attribute_groups, [:attributeGroup]
|