Class: FeedParser::LibXML::StrictFeedParserHandler

Inherits:
Object
  • Object
show all
Includes:
FeedParserMixin, LibXML::XML::SaxParser::Callbacks
Defined in:
lib/rfeedparser/libxml_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(baseuri, baselang, encoding) ⇒ StrictFeedParserHandler

Returns a new instance of StrictFeedParserHandler.



26
27
28
29
30
# File 'lib/rfeedparser/libxml_parser.rb', line 26

def initialize(baseuri, baselang, encoding)
  $stderr.puts "trying LibXML::StrictFeedParser" if $debug
  startup(baseuri, baselang, encoding)
  @bozo = false
end

Instance Attribute Details

#bozoObject

Returns the value of attribute bozo.



25
26
27
# File 'lib/rfeedparser/libxml_parser.rb', line 25

def bozo
  @bozo
end

#entriesObject

Returns the value of attribute entries.



25
26
27
# File 'lib/rfeedparser/libxml_parser.rb', line 25

def entries
  @entries
end

#excObject

Returns the value of attribute exc.



25
26
27
# File 'lib/rfeedparser/libxml_parser.rb', line 25

def exc
  @exc
end

#feeddataObject

Returns the value of attribute feeddata.



25
26
27
# File 'lib/rfeedparser/libxml_parser.rb', line 25

def feeddata
  @feeddata
end

Instance Method Details

#on_cdata_block(content) ⇒ Object



54
55
56
# File 'lib/rfeedparser/libxml_parser.rb', line 54

def on_cdata_block(content)
  handle_data(content)
end

#on_characters(text) ⇒ Object



50
51
52
# File 'lib/rfeedparser/libxml_parser.rb', line 50

def on_characters(text)
  handle_data(text)
end

#on_end_element(name) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/rfeedparser/libxml_parser.rb', line 58

def on_end_element(name)
  name =~ /^(([^;]*);)?(.+)$/ # Snag namespaceuri from name
  namespaceuri = ($2 || '').downcase
  prefix = @matchnamespaces[namespaceuri]
  if prefix and not prefix.empty?
    localname = prefix + ':' + name
  end
  name.downcase!
  unknown_endtag(name)
end

#on_parser_error(exc) ⇒ Object



69
70
71
72
73
# File 'lib/rfeedparser/libxml_parser.rb', line 69

def on_parser_error(exc)
  @bozo = true
  @exc = exc
  raise exc
end

#on_start_element(name, attrs) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rfeedparser/libxml_parser.rb', line 32

def on_start_element(name, attrs)
  name =~ /^(([^;]*);)?(.+)$/ # Snag namespaceuri from name
  namespaceuri = ($2 || '').downcase
  name = $3
  if /backend\.userland\.com\/rss/ =~ namespaceuri
    # match any backend.userland.com namespace
    namespaceuri = 'http://backend.userland.com/rss'
  end
  prefix = @matchnamespaces[namespaceuri]

  if prefix and not prefix.empty?
    name = prefix + ':' + name
  end

  name.downcase!
  unknown_starttag(name, attrs)
end