Class: Moxml::Adapter::REXMLStreamBridge

Inherits:
Object
  • Object
show all
Includes:
SAX::NamespaceSplitter, REXML::StreamListener
Defined in:
lib/moxml/adapter/rexml.rb

Overview

Bridge between REXML StreamParser and Moxml SAX

StreamParser (rather than SAX2Parser) is used because SAX2Parser normalizes plain "&#NN;" and "&#NN;" attribute literals to the same raw string, which makes spec-correct decoding impossible after the fact. StreamParser delivers attribute values in the same decoded form as REXML's DOM.

Constant Summary

Constants included from SAX::NamespaceSplitter

SAX::NamespaceSplitter::EMPTY_NAMESPACES

Instance Method Summary collapse

Methods included from SAX::NamespaceSplitter

#split_attributes_and_namespaces

Constructor Details

#initialize(handler) ⇒ REXMLStreamBridge

Returns a new instance of REXMLStreamBridge.



713
714
715
# File 'lib/moxml/adapter/rexml.rb', line 713

def initialize(handler)
  @handler = handler
end

Instance Method Details

#cdata(content) ⇒ Object



730
731
732
# File 'lib/moxml/adapter/rexml.rb', line 730

def cdata(content)
  @handler.on_cdata(content)
end

#comment(text) ⇒ Object



734
735
736
# File 'lib/moxml/adapter/rexml.rb', line 734

def comment(text)
  @handler.on_comment(text)
end

#instruction(target, data) ⇒ Object



738
739
740
# File 'lib/moxml/adapter/rexml.rb', line 738

def instruction(target, data)
  @handler.on_processing_instruction(target, data || "")
end

#tag_end(name) ⇒ Object



722
723
724
# File 'lib/moxml/adapter/rexml.rb', line 722

def tag_end(name)
  @handler.on_end_element(name)
end

#tag_start(name, attributes) ⇒ Object



717
718
719
720
# File 'lib/moxml/adapter/rexml.rb', line 717

def tag_start(name, attributes)
  attr_hash, ns_hash = split_attributes_and_namespaces(attributes)
  @handler.on_start_element(name, attr_hash, ns_hash)
end

#text(text) ⇒ Object



726
727
728
# File 'lib/moxml/adapter/rexml.rb', line 726

def text(text)
  @handler.on_characters(text)
end