Class: Lutaml::Xsd::NamespacePrefixManager

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/namespace_prefix_manager.rb

Overview

Manages namespace prefix information in a repository Single responsibility: analyze and report prefix usage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ NamespacePrefixManager

Returns a new instance of NamespacePrefixManager.



10
11
12
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 10

def initialize(repository)
  @repository = repository
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



8
9
10
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 8

def repository
  @repository
end

Instance Method Details

#detailed_prefix_infoObject

Get detailed prefix information Returns array of NamespacePrefixInfo objects



16
17
18
19
20
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 16

def detailed_prefix_info
  repository.namespace_mappings.map do |mapping|
    NamespacePrefixInfo.new(mapping, repository)
  end
end

#find_schema_for_namespace(namespace_uri) ⇒ Schema?

Find schema that defines a namespace

Parameters:

  • namespace_uri (String)

    The namespace URI

Returns:

  • (Schema, nil)

    The schema defining this namespace



25
26
27
28
29
30
31
32
33
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 25

def find_schema_for_namespace(namespace_uri)
  all_schemas = repository.send(:get_all_processed_schemas)

  all_schemas.each_value do |schema|
    return schema if schema.target_namespace == namespace_uri
  end

  nil
end

#get_package_location(namespace_uri) ⇒ String?

Get package location for namespace’s schema

Parameters:

  • namespace_uri (String)

    The namespace URI

Returns:

  • (String, nil)

    The file path or nil if not found



38
39
40
41
42
43
44
45
46
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 38

def get_package_location(namespace_uri)
  all_schemas = repository.send(:get_all_processed_schemas)

  all_schemas.each do |file_path, schema|
    return file_path if schema.target_namespace == namespace_uri
  end

  nil
end