Class: Lutaml::Xsd::SchemaLocationRule

Inherits:
ValidationRule show all
Defined in:
lib/lutaml/xsd/xsd_spec_validator.rb

Overview

Validates schemaLocation attributes

Instance Attribute Summary

Attributes inherited from ValidationRule

#version

Instance Method Summary collapse

Methods inherited from ValidationRule

#initialize

Constructor Details

This class inherits a constructor from Lutaml::Xsd::ValidationRule

Instance Method Details

#validate(repository) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/lutaml/xsd/xsd_spec_validator.rb', line 253

def validate(repository)
  errors = []
  warnings = []

  get_schemas(repository).each do |schema_file, schema|
    # Check imports
    imports = schema.import
    (imports || []).each do |import|
      next unless import.namespace

      warnings << "Import in #{File.basename(schema_file)} for namespace '#{import.namespace}' has no schemaLocation" if !import.schema_path || import.schema_path.empty?
    end

    # Check includes
    includes = schema.include
    (includes || []).each do |include|
      errors << "Include in #{File.basename(schema_file)} has no schemaLocation" if !include.schema_path || include.schema_path.empty?
    end
  end

  { errors: errors, warnings: warnings }
end