Class: RTM::XML::LibXMLSax2wrapper

Inherits:
Object
  • Object
show all
Includes:
LibXML::XML::SaxParser::Callbacks
Defined in:
rtm/lib/rtm/io/from_xtm2_libxml.rb

Overview

Acts as Callback structure for the LibXML-Ruby SAX Parser and calls a REXML SAX2Listener API.

Instance Method Summary

Constructor Details

- (LibXMLSax2wrapper) initialize(rexml_sax2listener)

A new instance of LibXMLSax2wrapper



38
39
40
41
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 38

def initialize(rexml_sax2listener)
  @dest = rexml_sax2listener
  @ns = Hash.new("http://www.topicmaps.org/xtm/")
end

Instance Method Details

- (Object) on_cdata_block(content)



71
72
73
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 71

def on_cdata_block(content)
  @dest.cdata(content)
end

- (Object) on_characters(text)



68
69
70
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 68

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

- (Object) on_end_document



45
46
47
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 45

def on_end_document
  @dest.end_document
end

- (Object) on_end_element(qname)



58
59
60
61
62
63
64
65
66
67
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 58

def on_end_element(qname)
  prefix, localname = qname.split(":")
  unless localname
    localname = prefix
    uri = @ns.default
  else
    uri = @ns[prefix]
  end
  @dest.end_element(uri, localname, qname)
end

- (Object) on_parser_error(msg)



74
75
76
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 74

def on_parser_error(msg)
 warn("SAX Parser Error: #{msg}")
end

- (Object) on_parser_fatal_error(msg)



80
81
82
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 80

def on_parser_fatal_error(msg)
  warn("SAX Parser Fatal Error: #{msg}")
end

- (Object) on_parser_warning(*msg)



77
78
79
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 77

def on_parser_warning(*msg)
  warn("SAX Parser Warning: #{msg}")
end

- (Object) on_start_document



42
43
44
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 42

def on_start_document
  @dest.start_document
end

- (Object) on_start_element(qname, attr)



48
49
50
51
52
53
54
55
56
57
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 48

def on_start_element(qname, attr)
  prefix, localname = qname.split(":")
  unless localname
    localname = prefix
    uri = @ns.default
  else
    uri = @ns[prefix]
  end
  @dest.start_element(uri, localname, qname, attr)
end