Class: Moxml::Adapter::REXMLSAX2Bridge

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

Overview

Bridge between REXML SAX2 and Moxml SAX

Translates REXML::SAX2Parser events to Moxml::SAX::Handler events

Instance Method Summary collapse

Methods included from SAX::NamespaceSplitter

#split_attributes_and_namespaces

Constructor Details

#initialize(handler) ⇒ REXMLSAX2Bridge

Returns a new instance of REXMLSAX2Bridge.



653
654
655
# File 'lib/moxml/adapter/rexml.rb', line 653

def initialize(handler)
  @handler = handler
end

Instance Method Details

#cdata(content) ⇒ Object



671
672
673
# File 'lib/moxml/adapter/rexml.rb', line 671

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

#characters(text) ⇒ Object



667
668
669
# File 'lib/moxml/adapter/rexml.rb', line 667

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

#comment(text) ⇒ Object



675
676
677
# File 'lib/moxml/adapter/rexml.rb', line 675

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

#end_documentObject



687
688
689
# File 'lib/moxml/adapter/rexml.rb', line 687

def end_document
  @handler.on_end_document
end

#end_element(_uri, _localname, qname) ⇒ Object



663
664
665
# File 'lib/moxml/adapter/rexml.rb', line 663

def end_element(_uri, _localname, qname)
  @handler.on_end_element(qname)
end

#processing_instruction(target, data) ⇒ Object



679
680
681
# File 'lib/moxml/adapter/rexml.rb', line 679

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

#progress(position) ⇒ Object



696
697
698
# File 'lib/moxml/adapter/rexml.rb', line 696

def progress(position)
  # Progress callback - we don't need to do anything
end

#start_documentObject



683
684
685
# File 'lib/moxml/adapter/rexml.rb', line 683

def start_document
  @handler.on_start_document
end

#start_element(_uri, _localname, qname, attributes) ⇒ Object

REXML splits element name into uri/localname/qname



658
659
660
661
# File 'lib/moxml/adapter/rexml.rb', line 658

def start_element(_uri, _localname, qname, attributes)
  attr_hash, ns_hash = split_attributes_and_namespaces(attributes)
  @handler.on_start_element(qname, attr_hash, ns_hash)
end

#xmldecl(version, encoding, standalone) ⇒ Object

REXML calls these but we don’t need to handle them



692
693
694
# File 'lib/moxml/adapter/rexml.rb', line 692

def xmldecl(version, encoding, standalone)
  # XML declaration - we don't need to do anything
end