Class: Lutaml::Xml::TypeNamespaceStrategy

Inherits:
NamespaceResolutionStrategy show all
Defined in:
lib/lutaml/xml/namespace_resolution_strategy.rb

Overview

Strategy for Type::Value with explicit namespace_class

Used when a custom Type::Value class declares its own namespace via ‘xml { namespace MyNamespace }`. The type’s namespace takes precedence over parent namespace.

Examples:

Custom Type with namespace

class CustomName < Lutaml::Model::Type::String
  xml do
    namespace MyNamespace
  end
end

<parent xmlns="http://example.com/parent">
  <custom:name xmlns:custom="http://example.com/custom">value</custom:name>
</parent>

Instance Attribute Summary

Attributes inherited from NamespaceResolutionStrategy

#namespace_uri, #prefix, #requires_blank_xmlns, #use_prefix

Instance Method Summary collapse

Methods inherited from NamespaceResolutionStrategy

#resolve

Constructor Details

#initialize(type_ns_decl, type_class) ⇒ TypeNamespaceStrategy

Initialize from type namespace declaration

Parameters:

  • type_ns_decl (NamespaceDeclaration)

    Type’s namespace declaration

  • type_class (Class)

    The Type::Value class (for reference)



136
137
138
139
140
141
142
# File 'lib/lutaml/xml/namespace_resolution_strategy.rb', line 136

def initialize(type_ns_decl, type_class)
  super(
    use_prefix: type_ns_decl.prefix_format?,
    prefix: type_ns_decl.prefix,
    namespace_uri: type_class.namespace_class.uri
  )
end