Class: Moxml::Adapter::Libxml::LibXMLSAXBridge

Inherits:
Object
  • Object
show all
Includes:
LibXML::XML::SaxParser::Callbacks, SAX::NamespaceSplitter
Defined in:
lib/moxml/adapter/libxml.rb

Overview

Bridge between LibXML SAX and Moxml SAX

Translates LibXML::XML::SaxParser events to Moxml::SAX::Handler events

Instance Method Summary collapse

Methods included from SAX::NamespaceSplitter

#split_attributes_and_namespaces

Constructor Details

#initialize(handler) ⇒ LibXMLSAXBridge

Returns a new instance of LibXMLSAXBridge.



1682
1683
1684
# File 'lib/moxml/adapter/libxml.rb', line 1682

def initialize(handler)
  @handler = handler
end

Instance Method Details

#on_cdata_block(content) ⇒ Object



1709
1710
1711
# File 'lib/moxml/adapter/libxml.rb', line 1709

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

#on_characters(chars) ⇒ Object



1705
1706
1707
# File 'lib/moxml/adapter/libxml.rb', line 1705

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

#on_comment(msg) ⇒ Object



1713
1714
1715
# File 'lib/moxml/adapter/libxml.rb', line 1713

def on_comment(msg)
  @handler.on_comment(msg)
end

#on_end_documentObject



1692
1693
1694
# File 'lib/moxml/adapter/libxml.rb', line 1692

def on_end_document
  @handler.on_end_document
end

#on_end_element(name) ⇒ Object



1701
1702
1703
# File 'lib/moxml/adapter/libxml.rb', line 1701

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

#on_error(msg) ⇒ Object



1721
1722
1723
# File 'lib/moxml/adapter/libxml.rb', line 1721

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

#on_processing_instruction(target, data) ⇒ Object



1717
1718
1719
# File 'lib/moxml/adapter/libxml.rb', line 1717

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

#on_start_documentObject

Map LibXML events to Moxml events



1688
1689
1690
# File 'lib/moxml/adapter/libxml.rb', line 1688

def on_start_document
  @handler.on_start_document
end

#on_start_element(name, attributes) ⇒ Object



1696
1697
1698
1699
# File 'lib/moxml/adapter/libxml.rb', line 1696

def on_start_element(name, attributes)
  attr_hash, ns_hash = split_attributes_and_namespaces(attributes)
  @handler.on_start_element(name.to_s, attr_hash, ns_hash)
end