Class: Moxml::C14n::NamespaceHandler
- Inherits:
-
Object
- Object
- Moxml::C14n::NamespaceHandler
- Defined in:
- lib/moxml/c14n/namespace_handler.rb
Overview
Namespace axis handler for inclusive C14N. Implements W3C C14N 1.0 §2.3 / 1.1 §2.3 namespace rendering rules for the document subset (full and partial).
Instance Attribute Summary collapse
-
#encoder ⇒ Object
readonly
Returns the value of attribute encoder.
Instance Method Summary collapse
-
#initialize(encoder) ⇒ NamespaceHandler
constructor
A new instance of NamespaceHandler.
- #process_namespaces(element, output, parent_element = nil) ⇒ Object
Constructor Details
#initialize(encoder) ⇒ NamespaceHandler
Returns a new instance of NamespaceHandler.
11 12 13 |
# File 'lib/moxml/c14n/namespace_handler.rb', line 11 def initialize(encoder) @encoder = encoder end |
Instance Attribute Details
#encoder ⇒ Object (readonly)
Returns the value of attribute encoder.
9 10 11 |
# File 'lib/moxml/c14n/namespace_handler.rb', line 9 def encoder @encoder end |
Instance Method Details
#process_namespaces(element, output, parent_element = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/moxml/c14n/namespace_handler.rb', line 15 def process_namespaces(element, output, parent_element = nil) return unless element.in_node_set? namespaces = element.sorted_namespace_nodes.select(&:in_node_set?) if should_emit_empty_default_namespace?(element, namespaces, parent_element) output << ' xmlns=""' end namespaces.each do |ns| next if should_skip_namespace?(ns, parent_element) output << " " output << (ns.default_namespace? ? "xmlns" : "xmlns:#{ns.prefix}") output << '="' output << encoder.encode_attribute(ns.uri) output << '"' end end |