Class: FeedParser::StrictFeedParser

Inherits:
XML::SAX::HandlerBase
  • Object
show all
Includes:
FeedParserMixin
Defined in:
lib/rfeedparser/parsers.rb

Overview

expat

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FeedParserMixin

#_parse_date_greek, #_parse_date_hungarian, #_parse_date_iso8601, #_parse_date_mssql, #_parse_date_nate, #_parse_date_onblog, #_parse_date_perforce, #_parse_date_rfc822, #_parse_date_w3dtf, #extract_tuple, #parse_date, #rollover, #set_self

Constructor Details

#initialize(baseuri, baselang, encoding) ⇒ StrictFeedParser

Returns a new instance of StrictFeedParser.



9
10
11
12
13
14
15
# File 'lib/rfeedparser/parsers.rb', line 9

def initialize(baseuri, baselang, encoding)
  $stderr << "trying StrictFeedParser\n" if $debug
  startup(baseuri, baselang, encoding) 
  @bozo = false
  @exc = nil
  super()
end

Instance Attribute Details

#bozoObject

Returns the value of attribute bozo.



8
9
10
# File 'lib/rfeedparser/parsers.rb', line 8

def bozo
  @bozo
end

#entriesObject

Returns the value of attribute entries.



8
9
10
# File 'lib/rfeedparser/parsers.rb', line 8

def entries
  @entries
end

#excObject

Returns the value of attribute exc.



8
9
10
# File 'lib/rfeedparser/parsers.rb', line 8

def exc
  @exc
end

#feeddataObject

Returns the value of attribute feeddata.



8
9
10
# File 'lib/rfeedparser/parsers.rb', line 8

def feeddata
  @feeddata
end

Instance Method Details

#character(text, start, length) ⇒ Object Also known as: characters



62
63
64
65
# File 'lib/rfeedparser/parsers.rb', line 62

def character(text, start, length)       
  #handle_data(CGI.unescapeHTML(text))
  handle_data(text)
end

#comment(comment) ⇒ Object



84
85
86
# File 'lib/rfeedparser/parsers.rb', line 84

def comment(comment)
  handle_comment(comment)
end

#endElement(name) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/rfeedparser/parsers.rb', line 73

def endElement(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

#endNamespaceDecl(prefix) ⇒ Object



41
42
# File 'lib/rfeedparser/parsers.rb', line 41

def endNamespaceDecl(prefix)
end

#entityDecl(*foo) ⇒ Object



88
89
# File 'lib/rfeedparser/parsers.rb', line 88

def entityDecl(*foo)
end

#error(exc) ⇒ Object



93
94
95
96
# File 'lib/rfeedparser/parsers.rb', line 93

def error(exc)
  @bozo = true 
  @exc = exc
end

#fatalError(exc) ⇒ Object



98
99
100
101
# File 'lib/rfeedparser/parsers.rb', line 98

def fatalError(exc)
  error(exc)
  raise exc
end

#getAttrs(attrs) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rfeedparser/parsers.rb', line 21

def getAttrs(attrs)
  ret = []
  for i in 0..attrs.getLength
    ret.push([attrs.getName(i), attrs.getValue(i)])
  end
  ret
end

#getPosObject



17
18
19
# File 'lib/rfeedparser/parsers.rb', line 17

def getPos
  [@locator.getSystemId, @locator.getLineNumber]
end

#setDocumentLocator(loc) ⇒ Object



29
30
31
# File 'lib/rfeedparser/parsers.rb', line 29

def setDocumentLocator(loc)
  @locator = loc
end

#startCdata(content) ⇒ Object

Just in case.



69
70
71
# File 'lib/rfeedparser/parsers.rb', line 69

def startCdata(content)
  handle_data(content)
end

#startDoctypeDecl(name, pub_sys, long_name, uri) ⇒ Object



33
34
35
# File 'lib/rfeedparser/parsers.rb', line 33

def startDoctypeDecl(name, pub_sys, long_name, uri)   
  #Nothing is done here. What could we do that is neat and useful?
end

#startElement(name, attrs) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rfeedparser/parsers.rb', line 44

def startElement(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] 
  # No need to raise UndeclaredNamespace, Expat does that for us with
  "unbound prefix (XMLParserError)"
  if prefix and not prefix.empty?
    name = prefix + ':' + name
  end
  name.downcase!
  unknown_starttag(name, attrs)
end

#startNamespaceDecl(prefix, uri) ⇒ Object



37
38
39
# File 'lib/rfeedparser/parsers.rb', line 37

def startNamespaceDecl(prefix, uri)
  trackNamespace(prefix, uri)
end

#unparsedEntityDecl(*foo) ⇒ Object



91
92
# File 'lib/rfeedparser/parsers.rb', line 91

def unparsedEntityDecl(*foo)
end