Class: Moxml::Adapter::Nokogiri::NokogiriSAXBridge

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Includes:
SAX::NamespaceSplitter
Defined in:
lib/moxml/adapter/nokogiri.rb

Overview

Bridge between Nokogiri SAX and Moxml SAX

Translates Nokogiri::XML::SAX::Document events to Moxml::SAX::Handler events

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) ⇒ NokogiriSAXBridge

Returns a new instance of NokogiriSAXBridge.



588
589
590
591
# File 'lib/moxml/adapter/nokogiri.rb', line 588

def initialize(handler)
  super()
  @handler = handler
end

Instance Method Details

#cdata_block(string) ⇒ Object



618
619
620
# File 'lib/moxml/adapter/nokogiri.rb', line 618

def cdata_block(string)
  @handler.on_cdata(string)
end

#characters(string) ⇒ Object



614
615
616
# File 'lib/moxml/adapter/nokogiri.rb', line 614

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

#comment(string) ⇒ Object



622
623
624
# File 'lib/moxml/adapter/nokogiri.rb', line 622

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

#end_document ⇒ Object



599
600
601
# File 'lib/moxml/adapter/nokogiri.rb', line 599

def end_document
  @handler.on_end_document
end

#end_element(name) ⇒ Object



610
611
612
# File 'lib/moxml/adapter/nokogiri.rb', line 610

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

#error(string) ⇒ Object



630
631
632
# File 'lib/moxml/adapter/nokogiri.rb', line 630

def error(string)
  @handler.on_error(Moxml::ParseError.new(string))
end

#processing_instruction(target, data) ⇒ Object



626
627
628
# File 'lib/moxml/adapter/nokogiri.rb', line 626

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

#start_document ⇒ Object

Map Nokogiri events to Moxml events



595
596
597
# File 'lib/moxml/adapter/nokogiri.rb', line 595

def start_document
  @handler.on_start_document
end

#start_element(name, attributes = []) ⇒ Object



603
604
605
606
607
608
# File 'lib/moxml/adapter/nokogiri.rb', line 603

def start_element(name, attributes = [])
  attr_hash, ns_hash = split_attributes_and_namespaces(attributes) do |v|
    Moxml::Adapter::Base.decode_entities(v)
  end
  @handler.on_start_element(name, attr_hash, ns_hash)
end

#warning(string) ⇒ Object



634
635
636
# File 'lib/moxml/adapter/nokogiri.rb', line 634

def warning(string)
  @handler.on_warning(string)
end