Class: RSS::XMLScanListener

Inherits:
BaseListener show all
Includes:
ListenerMixin, XMLScan::Visitor
Defined in:
lib/rss/xmlscanner.rb

Constant Summary collapse

ENTITIES =
{
  'lt' => '<',
  'gt' => '>',
  'amp' => '&',
  'quot' => '"',
  'apos' => '\''
}

Instance Attribute Summary

Attributes included from ListenerMixin

#do_validate, #ignore_unknown_element, #rss

Instance Method Summary collapse

Methods included from ListenerMixin

#initialize, #instruction, #tag_end, #tag_start, #text, #xmldecl

Methods inherited from BaseListener

available_tags, class_name, getter, install_class_name, install_get_text_element, raise_for_undefined_entity?, register_uri, setter, uri_registered?

Methods included from Utils

element_initialize_arguments?, get_file_and_line_from_caller, new_with_value_if_need, to_class_name

Instance Method Details

#on_attr_charref(code) ⇒ Object Also known as: on_attr_charref_hex



96
97
98
# File 'lib/rss/xmlscanner.rb', line 96

def on_attr_charref(code)
  @current_attr << [code].pack('U')
end

#on_attr_entityref(ref) ⇒ Object



92
93
94
# File 'lib/rss/xmlscanner.rb', line 92

def on_attr_entityref(ref)
  @current_attr << entity(ref)
end

#on_attr_value(str) ⇒ Object



88
89
90
# File 'lib/rss/xmlscanner.rb', line 88

def on_attr_value(str)
  @current_attr << str
end

#on_attribute(name) ⇒ Object



84
85
86
# File 'lib/rss/xmlscanner.rb', line 84

def on_attribute(name)
  @attrs[name] = @current_attr = ''
end

#on_charref(code) ⇒ Object Also known as: on_charref_hex



74
75
76
# File 'lib/rss/xmlscanner.rb', line 74

def on_charref(code)
  text([code].pack('U'))
end

#on_entityref(ref) ⇒ Object



70
71
72
# File 'lib/rss/xmlscanner.rb', line 70

def on_entityref(ref)
  text(entity(ref))
end

#on_etag(name) ⇒ Object



66
67
68
# File 'lib/rss/xmlscanner.rb', line 66

def on_etag(name)
  tag_end(name)
end

#on_stag(name) ⇒ Object



80
81
82
# File 'lib/rss/xmlscanner.rb', line 80

def on_stag(name)
  @attrs = {}
end

#on_stag_end(name) ⇒ Object



102
103
104
# File 'lib/rss/xmlscanner.rb', line 102

def on_stag_end(name)
  tag_start(name, @attrs)
end

#on_stag_end_empty(name) ⇒ Object



106
107
108
109
# File 'lib/rss/xmlscanner.rb', line 106

def on_stag_end_empty(name)
  tag_start(name, @attrs)
  tag_end(name)
end

#on_xmldecl_encoding(str) ⇒ Object



50
51
52
# File 'lib/rss/xmlscanner.rb', line 50

def on_xmldecl_encoding(str)
  @encoding = str
end

#on_xmldecl_endObject



58
59
60
# File 'lib/rss/xmlscanner.rb', line 58

def on_xmldecl_end
  xmldecl(@version, @encoding, @standalone == "yes")
end

#on_xmldecl_standalone(str) ⇒ Object



54
55
56
# File 'lib/rss/xmlscanner.rb', line 54

def on_xmldecl_standalone(str)
  @standalone = str
end

#on_xmldecl_version(str) ⇒ Object



46
47
48
# File 'lib/rss/xmlscanner.rb', line 46

def on_xmldecl_version(str)
  @version = str
end