Class: Lutaml::Xml::BlankNamespaceStrategy

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

Overview

Strategy for elements that should be in blank namespace

Used for native types (‘:string`, `:integer`, etc.) WITHOUT explicit `xml_namespace` declaration. These elements should serialize in the blank namespace even when their parent uses a namespace.

W3C Compliance:

  • If parent uses PREFIX format: no xmlns needed

  • If parent uses DEFAULT format: xmlns=“” must be added to prevent inheritance

Examples:

XML output with parent using prefix format

<first:parent xmlns:first="http://example.com">
  <child>value</child>  <!-- blank namespace, no xmlns needed -->
</first:parent>

XML output with parent using default format

<parent xmlns="http://example.com">
  <child xmlns="">value</child>  <!-- xmlns="" prevents inheritance -->
</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(parent_uses_default: false) ⇒ BlankNamespaceStrategy

Initialize with blank namespace settings

Parameters:

  • parent_uses_default (Boolean) (defaults to: false)

    Whether parent uses default namespace format



75
76
77
78
79
80
81
82
# File 'lib/lutaml/xml/namespace_resolution_strategy.rb', line 75

def initialize(parent_uses_default: false)
  super(
    use_prefix: false,
    prefix: nil,
    namespace_uri: nil,
    requires_blank_xmlns: parent_uses_default
  )
end