Class: Lutaml::Xsd::NamespaceConsistencyRule
- Inherits:
-
ValidationRule
- Object
- ValidationRule
- Lutaml::Xsd::NamespaceConsistencyRule
- Defined in:
- lib/lutaml/xsd/xsd_spec_validator.rb
Overview
Validates namespace consistency
Instance Attribute Summary
Attributes inherited from ValidationRule
Instance Method Summary collapse
Methods inherited from ValidationRule
Constructor Details
This class inherits a constructor from Lutaml::Xsd::ValidationRule
Instance Method Details
#validate(repository) ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/lutaml/xsd/xsd_spec_validator.rb', line 283 def validate(repository) errors = [] warnings = [] # Track which namespaces are defined in which files namespace_files = {} get_schemas(repository).each do |schema_file, schema| namespace = schema.target_namespace next unless namespace namespace_files[namespace] ||= [] namespace_files[namespace] << schema_file end # Check for namespaces defined in multiple files namespace_files.each do |namespace, files| next unless files.size > 1 warnings << "Namespace '#{namespace}' is defined in #{files.size} schemas: #{files.map do |f| File.basename(f) end.join(', ')}" end { errors: errors, warnings: warnings } end |