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.



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

def initialize(handler)
  @handler = handler
end

Instance Method Details

#cdata(content) ⇒ Object



748
749
750
# File 'lib/moxml/adapter/rexml.rb', line 748

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

#comment(text) ⇒ Object



752
753
754
# File 'lib/moxml/adapter/rexml.rb', line 752

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

#instruction(target, data) ⇒ Object



756
757
758
# File 'lib/moxml/adapter/rexml.rb', line 756

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

#tag_end(name) ⇒ Object



740
741
742
# File 'lib/moxml/adapter/rexml.rb', line 740

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

#tag_start(name, attributes) ⇒ Object



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

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



744
745
746
# File 'lib/moxml/adapter/rexml.rb', line 744

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