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

Instance Method Summary collapse

Methods included from SAX::NamespaceSplitter

#split_attributes_and_namespaces

Constructor Details

#initialize(handler) ⇒ NokogiriSAXBridge

Returns a new instance of NokogiriSAXBridge.



456
457
458
459
# File 'lib/moxml/adapter/nokogiri.rb', line 456

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

Instance Method Details

#cdata_block(string) ⇒ Object



484
485
486
# File 'lib/moxml/adapter/nokogiri.rb', line 484

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

#characters(string) ⇒ Object



480
481
482
# File 'lib/moxml/adapter/nokogiri.rb', line 480

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

#comment(string) ⇒ Object



488
489
490
# File 'lib/moxml/adapter/nokogiri.rb', line 488

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

#end_documentObject



467
468
469
# File 'lib/moxml/adapter/nokogiri.rb', line 467

def end_document
  @handler.on_end_document
end

#end_element(name) ⇒ Object



476
477
478
# File 'lib/moxml/adapter/nokogiri.rb', line 476

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

#error(string) ⇒ Object



496
497
498
# File 'lib/moxml/adapter/nokogiri.rb', line 496

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

#processing_instruction(target, data) ⇒ Object



492
493
494
# File 'lib/moxml/adapter/nokogiri.rb', line 492

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

#start_documentObject

Map Nokogiri events to Moxml events



463
464
465
# File 'lib/moxml/adapter/nokogiri.rb', line 463

def start_document
  @handler.on_start_document
end

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



471
472
473
474
# File 'lib/moxml/adapter/nokogiri.rb', line 471

def start_element(name, attributes = [])
  attr_hash, ns_hash = split_attributes_and_namespaces(attributes)
  @handler.on_start_element(name, attr_hash, ns_hash)
end

#warning(string) ⇒ Object



500
501
502
# File 'lib/moxml/adapter/nokogiri.rb', line 500

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