Class: Lutaml::Xsd::Validation::SchemaResolver
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Validation::SchemaResolver
- Defined in:
- lib/lutaml/xsd/validation/schema_resolver.rb
Overview
SchemaResolver resolves XSD schemas from locations
This class takes schema location hints from XML documents and resolves them to actual XSD schema objects using the SchemaRepository.
Instance Attribute Summary collapse
-
#repository ⇒ SchemaRepository
readonly
The schema repository.
Instance Method Summary collapse
-
#can_resolve_all?(document) ⇒ Boolean
Check if all schemas for a document can be resolved.
-
#initialize(repository) ⇒ SchemaResolver
constructor
Initialize a new SchemaResolver.
-
#missing_schemas(document) ⇒ Array<String>
Get missing schema locations for a document.
-
#resolve_by_location(_location) ⇒ Schema?
Resolve a single schema by location.
-
#resolve_by_namespace(namespace) ⇒ Schema?
Resolve a single schema by namespace.
-
#resolve_from_document(document) ⇒ Hash
Resolve schemas from an XML document.
-
#resolve_from_locations(locations, no_namespace_location = nil) ⇒ Hash
Resolve schemas from explicit locations.
Constructor Details
#initialize(repository) ⇒ SchemaResolver
Initialize a new SchemaResolver
27 28 29 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 27 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ SchemaRepository (readonly)
Returns The schema repository.
22 23 24 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 22 def repository @repository end |
Instance Method Details
#can_resolve_all?(document) ⇒ Boolean
Check if all schemas for a document can be resolved
90 91 92 93 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 90 def can_resolve_all?(document) result = resolve_from_document(document) result[:unresolved].empty? end |
#missing_schemas(document) ⇒ Array<String>
Get missing schema locations for a document
99 100 101 102 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 99 def missing_schemas(document) result = resolve_from_document(document) result[:unresolved] end |
#resolve_by_location(_location) ⇒ Schema?
Resolve a single schema by location
76 77 78 79 80 81 82 83 84 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 76 def resolve_by_location(_location) # This is a simplified implementation # In a real implementation, this would: # 1. Check if location is in repository # 2. Try to load from file system # 3. Try to download if URL # 4. Parse and add to repository nil end |
#resolve_by_namespace(namespace) ⇒ Schema?
Resolve a single schema by namespace
66 67 68 69 70 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 66 def resolve_by_namespace(namespace) @repository.schemas.find do |schema| schema.target_namespace == namespace end end |
#resolve_from_document(document) ⇒ Hash
Resolve schemas from an XML document
Extracts schema locations from the document and resolves them to schema objects.
45 46 47 48 49 50 51 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 45 def resolve_from_document(document) extractor = SchemaLocationExtractor.new(document) locations = extractor.extract_schema_locations no_ns_location = extractor.extract_no_namespace_schema_location resolve_all_locations(locations, no_ns_location) end |
#resolve_from_locations(locations, no_namespace_location = nil) ⇒ Hash
Resolve schemas from explicit locations
58 59 60 |
# File 'lib/lutaml/xsd/validation/schema_resolver.rb', line 58 def resolve_from_locations(locations, no_namespace_location = nil) resolve_all_locations(locations, no_namespace_location) end |