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.



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

def initialize(handler)
  @handler = handler
end

Instance Method Details

#cdata(content) ⇒ Object



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

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

#comment(text) ⇒ Object



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

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

#instruction(target, data) ⇒ Object



759
760
761
# File 'lib/moxml/adapter/rexml.rb', line 759

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

#tag_end(name) ⇒ Object



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

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

#tag_start(name, attributes) ⇒ Object



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

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



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

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