Class: Lutaml::Xml::Adapter::NamespaceData Private
- Inherits:
-
Object
- Object
- Lutaml::Xml::Adapter::NamespaceData
- Defined in:
- lib/lutaml/xml/adapter/namespace_data.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Simple data class for holding namespace URI and prefix pairs during XML parsing and serialization.
This is an internal class used by XML adapters. For defining custom namespaces, use Lutaml::Xml::Namespace instead.
Instance Attribute Summary collapse
-
#prefix ⇒ String
private
Return prefix.
-
#uri ⇒ String
private
Return URI.
Instance Method Summary collapse
- #attr_name ⇒ Object private
-
#initialize(uri = nil, prefix = nil) ⇒ NamespaceData
constructor
private
Initialize instance.
- #normalize_prefix(prefix) ⇒ Object private
Constructor Details
#initialize(uri = nil, prefix = nil) ⇒ NamespaceData
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize instance
28 29 30 31 |
# File 'lib/lutaml/xml/adapter/namespace_data.rb', line 28 def initialize(uri = nil, prefix = nil) @uri = uri @prefix = normalize_prefix(prefix) end |
Instance Attribute Details
#prefix ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return prefix
22 23 24 |
# File 'lib/lutaml/xml/adapter/namespace_data.rb', line 22 def prefix @prefix end |
#uri ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return URI
17 18 19 |
# File 'lib/lutaml/xml/adapter/namespace_data.rb', line 17 def uri @uri end |
Instance Method Details
#attr_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 |
# File 'lib/lutaml/xml/adapter/namespace_data.rb', line 46 def attr_name if ::Lutaml::Model::Utils.present?(prefix) "xmlns:#{prefix}" else "xmlns" end end |
#normalize_prefix(prefix) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lutaml/xml/adapter/namespace_data.rb', line 33 def normalize_prefix(prefix) # Only strip "xmlns:" prefix (e.g., "xmlns:foo" → "foo"). # Do NOT strip "xmlns" from prefixes like "xmlns_1.0" (valid NCName). # Bare "xmlns" (no colon) represents the default namespace → return nil. prefix_str = prefix.to_s return nil if prefix_str == "xmlns" normalized_prefix = prefix_str.sub(/^xmlns:/, "") return if normalized_prefix.empty? normalized_prefix end |