Module: Lutaml::Xml::Schema::Xsd
- Defined in:
- lib/lutaml/xml/schema/xsd.rb,
lib/lutaml/xml/schema/xsd/all.rb,
lib/lutaml/xml/schema/xsd/any.rb,
lib/lutaml/xml/schema/xsd/key.rb,
lib/lutaml/xml/schema/xsd/base.rb,
lib/lutaml/xml/schema/xsd/glob.rb,
lib/lutaml/xml/schema/xsd/list.rb,
lib/lutaml/xml/schema/xsd/field.rb,
lib/lutaml/xml/schema/xsd/group.rb,
lib/lutaml/xml/schema/xsd/union.rb,
lib/lutaml/xml/schema/xsd/choice.rb,
lib/lutaml/xml/schema/xsd/errors.rb,
lib/lutaml/xml/schema/xsd/import.rb,
lib/lutaml/xml/schema/xsd/keyref.rb,
lib/lutaml/xml/schema/xsd/length.rb,
lib/lutaml/xml/schema/xsd/schema.rb,
lib/lutaml/xml/schema/xsd/unique.rb,
lib/lutaml/xml/schema/xsd/appinfo.rb,
lib/lutaml/xml/schema/xsd/element.rb,
lib/lutaml/xml/schema/xsd/include.rb,
lib/lutaml/xml/schema/xsd/pattern.rb,
lib/lutaml/xml/schema/xsd/version.rb,
lib/lutaml/xml/schema/xsd/notation.rb,
lib/lutaml/xml/schema/xsd/redefine.rb,
lib/lutaml/xml/schema/xsd/selector.rb,
lib/lutaml/xml/schema/xsd/sequence.rb,
lib/lutaml/xml/schema/xsd/attribute.rb,
lib/lutaml/xml/schema/xsd/annotation.rb,
lib/lutaml/xml/schema/xsd/max_length.rb,
lib/lutaml/xml/schema/xsd/min_length.rb,
lib/lutaml/xml/schema/xsd/enumeration.rb,
lib/lutaml/xml/schema/xsd/schema_path.rb,
lib/lutaml/xml/schema/xsd/simple_type.rb,
lib/lutaml/xml/schema/xsd/white_space.rb,
lib/lutaml/xml/schema/xsd/complex_type.rb,
lib/lutaml/xml/schema/xsd/total_digits.rb,
lib/lutaml/xml/schema/xsd/any_attribute.rb,
lib/lutaml/xml/schema/xsd/documentation.rb,
lib/lutaml/xml/schema/xsd/max_exclusive.rb,
lib/lutaml/xml/schema/xsd/max_inclusive.rb,
lib/lutaml/xml/schema/xsd/min_exclusive.rb,
lib/lutaml/xml/schema/xsd/min_inclusive.rb,
lib/lutaml/xml/schema/xsd/simple_content.rb,
lib/lutaml/xml/schema/xsd/attribute_group.rb,
lib/lutaml/xml/schema/xsd/complex_content.rb,
lib/lutaml/xml/schema/xsd/fraction_digits.rb,
lib/lutaml/xml/schema/xsd/schema_validator.rb,
lib/lutaml/xml/schema/xsd/type_index_entry.rb,
lib/lutaml/xml/schema/xsd/validation_error.rb,
lib/lutaml/xml/schema/xsd/errors/suggestion.rb,
lib/lutaml/xml/schema/xsd/namespace_mapping.rb,
lib/lutaml/xml/schema/xsd/serialized_schema.rb,
lib/lutaml/xml/schema/xsd/validation_result.rb,
lib/lutaml/xml/schema/xsd/errors/error_context.rb,
lib/lutaml/xml/schema/xsd/schema_name_resolver.rb,
lib/lutaml/xml/schema/xsd/errors/enhanced_error.rb,
lib/lutaml/xml/schema/xsd/errors/message_builder.rb,
lib/lutaml/xml/schema/xsd/file_validation_result.rb,
lib/lutaml/xml/schema/xsd/type_resolution_result.rb,
lib/lutaml/xml/schema/xsd/namespace_uri_remapping.rb,
lib/lutaml/xml/schema/xsd/restriction_simple_type.rb,
lib/lutaml/xml/schema/xsd/schema_location_mapping.rb,
lib/lutaml/xml/schema/xsd/extension_simple_content.rb,
lib/lutaml/xml/schema/xsd/extension_complex_content.rb,
lib/lutaml/xml/schema/xsd/restriction_simple_content.rb,
lib/lutaml/xml/schema/xsd/restriction_complex_content.rb,
lib/lutaml/xml/schema/xsd/schema_file_validation_results.rb,
lib/lutaml/xml/schema/xsd/errors/troubleshooters/troubleshooting_handler.rb,
lib/lutaml/xml/schema/xsd/errors/troubleshooters/namespace_troubleshooter.rb
Defined Under Namespace
Modules: Errors, Glob
Classes: All, Annotation, Any, AnyAttribute, Appinfo, Attribute, AttributeGroup, Base, Choice, ComplexContent, ComplexType, ConfigurationError, Documentation, Element, Enumeration, Error, ExtensionComplexContent, ExtensionSimpleContent, Field, FileValidationResult, FractionDigits, Group, Import, Include, Key, Keyref, Length, List, MaxExclusive, MaxInclusive, MaxLength, MinExclusive, MinInclusive, MinLength, NamespaceMapping, NamespaceUriRemapping, Notation, PackageMergeError, PackageValidationError, Pattern, Redefine, RestrictionComplexContent, RestrictionSimpleContent, RestrictionSimpleType, Schema, SchemaFileValidationResults, SchemaLocationMapping, SchemaNameResolver, SchemaNotFoundError, SchemaPath, SchemaValidationError, SchemaValidator, Selector, Sequence, SerializedSchema, SimpleContent, SimpleType, TotalDigits, TypeIndexEntry, TypeNotFoundError, TypeResolutionResult, Union, Unique, ValidationError, ValidationFailedError, ValidationResult, WhiteSpace
Constant Summary
collapse
- XSD_AUTOLOAD_CLASSES =
List of all XSD model classes that need to be autoloaded and registered. This is used in parse() to ensure all types are registered before parsing.
%i[
All Annotation Any AnyAttribute Appinfo Attribute AttributeGroup
Choice ComplexContent ComplexType Documentation Element Enumeration
ExtensionComplexContent ExtensionSimpleContent Field FractionDigits
Glob Group Import Include Key Keyref Length List MaxExclusive
MaxInclusive MaxLength MinExclusive MinInclusive MinLength
Notation Pattern Redefine RestrictionComplexContent
RestrictionSimpleContent RestrictionSimpleType Schema SchemaPath
Selector Sequence SimpleContent SimpleType TotalDigits Union Unique
WhiteSpace SchemaFileValidationResults
].freeze
- VERSION =
"1.0.4"
Class Method Summary
collapse
Class Method Details
.parse(xsd, location: nil, nested_schema: false, register: nil, schema_mappings: nil, validate_schema: true) ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/lutaml/xml/schema/xsd.rb', line 138
def parse(xsd, location: nil, nested_schema: false, register: nil,
schema_mappings: nil, validate_schema: true)
XSD_AUTOLOAD_CLASSES.each { |c| const_get(c) unless c == :VERSION }
if validate_schema && !nested_schema
detected_version = SchemaValidator.detect_version(xsd)
validator = SchemaValidator.new(version: detected_version)
validator.validate(xsd)
end
register ||= self.register
Glob.schema_mappings = schema_mappings
Schema.reset_processed_schemas unless nested_schema
Glob.with_location(location) do
Schema.from_xml(xsd, register: register).assign_root!
end
end
|
.register_model(klass, id) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/lutaml/xml/schema/xsd.rb', line 121
def register_model(klass, id)
register.register_model(klass, id: id)
default_ctx = Lutaml::Model::GlobalContext.default_context
unless default_ctx.registry.registered?(id)
default_ctx.registry.register(id, klass)
end
klass_name = klass.to_s
unless default_ctx.registry.registered?(klass_name.to_sym)
default_ctx.registry.register(klass_name.to_sym, klass)
end
end
|