Class: FeedParser::Nokogiri::StrictFeedParserHandler

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Includes:
FeedParserMixin
Defined in:
lib/rfeedparser/nokogiri_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(baseuri, baselang, encoding) ⇒ StrictFeedParserHandler

Returns a new instance of StrictFeedParserHandler.



27
28
29
30
31
# File 'lib/rfeedparser/nokogiri_parser.rb', line 27

def initialize(baseuri, baselang, encoding)
  $stderr.puts "trying Nokogiri::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/nokogiri_parser.rb', line 25

def bozo
  @bozo
end

#entriesObject

Returns the value of attribute entries.



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

def entries
  @entries
end

#excObject

Returns the value of attribute exc.



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

def exc
  @exc
end

#feeddataObject

Returns the value of attribute feeddata.



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

def feeddata
  @feeddata
end

Instance Method Details

#cdata_block(text) ⇒ Object



55
56
57
# File 'lib/rfeedparser/nokogiri_parser.rb', line 55

def cdata_block(text)
  handle_data(text)
end

#characters(text) ⇒ Object



51
52
53
# File 'lib/rfeedparser/nokogiri_parser.rb', line 51

def characters(text)
  handle_data(text)
end

#end_element(name) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rfeedparser/nokogiri_parser.rb', line 59

def end_element(name)
  name =~ /^(([^;]*);)?(.+)$/ # Snag namespaceuri from name
  namespaceuri = ($2 || '').downcase

  prefix = @matchnamespaces[namespaceuri]

  if prefix && !prefix.empty?
   localname = prefix + ':' + name
  end

  name.downcase!
  unknown_endtag(name)
end

#error(error_string) ⇒ Object

Raises:



73
74
75
76
77
# File 'lib/rfeedparser/nokogiri_parser.rb', line 73

def error(error_string)
  @bozo = true
  @exc = NokogiriSyntaxError.new(error_string)
  raise @exc
end

#start_element(name, attrs) ⇒ Object



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

def 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 && !prefix.empty?
    name = prefix + ':' + name
  end

  name.downcase!
  unknown_starttag(name, attrs)
end