Class: Lutaml::Xml::DeclarationPlan::ElementNode
- Inherits:
-
Object
- Object
- Lutaml::Xml::DeclarationPlan::ElementNode
- Defined in:
- lib/lutaml/xml/declaration_plan/element_node.rb
Overview
ElementNode represents namespace decisions for a single XML element in the tree
This is a PURE DATA structure - it stores decisions made by DeclarationPlanner but contains NO decision-making logic itself.
The ElementNode tree is isomorphic to the XmlDataModel tree, allowing adapters to traverse both trees in parallel by index/position.
Instance Attribute Summary collapse
-
#attribute_nodes ⇒ Array<AttributeNode>
readonly
Attribute decisions (matched by index to XmlDataModel).
-
#element_nodes ⇒ Array<ElementNode>
readonly
Child element decisions (matched by index to XmlDataModel).
-
#hoisted_declarations ⇒ Hash<String, String>
readonly
Xmlns declarations to emit at this element Keys: “xmlns” or “xmlns:prefix” Values: namespace URIs.
-
#needs_xmlns_blank ⇒ Boolean
readonly
Whether this element needs xmlns=“” declaration (W3C compliance) True when element is in blank namespace AND parent uses default format.
-
#qualified_name ⇒ String
readonly
Element name with prefix (e.g., “prefix:element” or “element”).
-
#schema_location_attr ⇒ Hash?
readonly
Schema location attribute to emit (key: attr name, value) e.g., { “xsi:schemaLocation” => “uri1 loc1 uri2 loc2” }.
-
#use_prefix ⇒ String?
readonly
Prefix to use for this element (nil for default format).
Instance Method Summary collapse
-
#add_attribute_node(node) ⇒ AttributeNode
Add an attribute decision node.
-
#add_element_node(node) ⇒ ElementNode
Add a child element decision node.
-
#initialize(qualified_name:, use_prefix:, hoisted_declarations: {}, needs_xmlns_blank: false, schema_location_attr: nil) ⇒ ElementNode
constructor
Initialize an element node.
-
#uses_default_format? ⇒ Boolean
Check if this element uses default namespace format.
-
#uses_prefix_format? ⇒ Boolean
Check if this element uses prefix format.
Constructor Details
#initialize(qualified_name:, use_prefix:, hoisted_declarations: {}, needs_xmlns_blank: false, schema_location_attr: nil) ⇒ ElementNode
Initialize an element node
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 56 def initialize(qualified_name:, use_prefix:, hoisted_declarations: {}, needs_xmlns_blank: false, schema_location_attr: nil) @qualified_name = qualified_name @use_prefix = use_prefix @hoisted_declarations = hoisted_declarations @attribute_nodes = [] @element_nodes = [] @needs_xmlns_blank = needs_xmlns_blank @schema_location_attr = schema_location_attr end |
Instance Attribute Details
#attribute_nodes ⇒ Array<AttributeNode> (readonly)
Returns Attribute decisions (matched by index to XmlDataModel).
36 37 38 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 36 def attribute_nodes @attribute_nodes end |
#element_nodes ⇒ Array<ElementNode> (readonly)
Returns Child element decisions (matched by index to XmlDataModel).
39 40 41 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 39 def element_nodes @element_nodes end |
#hoisted_declarations ⇒ Hash<String, String> (readonly)
Returns xmlns declarations to emit at this element Keys: “xmlns” or “xmlns:prefix” Values: namespace URIs.
33 34 35 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 33 def hoisted_declarations @hoisted_declarations end |
#needs_xmlns_blank ⇒ Boolean (readonly)
Returns Whether this element needs xmlns=“” declaration (W3C compliance) True when element is in blank namespace AND parent uses default format.
43 44 45 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 43 def needs_xmlns_blank @needs_xmlns_blank end |
#qualified_name ⇒ String (readonly)
Returns Element name with prefix (e.g., “prefix:element” or “element”).
25 26 27 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 25 def qualified_name @qualified_name end |
#schema_location_attr ⇒ Hash? (readonly)
Returns Schema location attribute to emit (key: attr name, value) e.g., { “xsi:schemaLocation” => “uri1 loc1 uri2 loc2” }.
47 48 49 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 47 def schema_location_attr @schema_location_attr end |
#use_prefix ⇒ String? (readonly)
Returns Prefix to use for this element (nil for default format).
28 29 30 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 28 def use_prefix @use_prefix end |
Instance Method Details
#add_attribute_node(node) ⇒ AttributeNode
Add an attribute decision node
71 72 73 74 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 71 def add_attribute_node(node) @attribute_nodes << node node end |
#add_element_node(node) ⇒ ElementNode
Add a child element decision node
80 81 82 83 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 80 def add_element_node(node) @element_nodes << node node end |
#uses_default_format? ⇒ Boolean
Check if this element uses default namespace format
88 89 90 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 88 def uses_default_format? use_prefix.nil? end |
#uses_prefix_format? ⇒ Boolean
Check if this element uses prefix format
95 96 97 |
# File 'lib/lutaml/xml/declaration_plan/element_node.rb', line 95 def uses_prefix_format? !use_prefix.nil? end |