Class: FeedParser::Expat::StrictFeedParserHandler

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

Overview

expat

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(baseuri, baselang, encoding) ⇒ StrictFeedParserHandler

Returns a new instance of StrictFeedParserHandler.



44
45
46
47
48
49
50
# File 'lib/rfeedparser/expat_parser.rb', line 44

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.



43
44
45
# File 'lib/rfeedparser/expat_parser.rb', line 43

def bozo
  @bozo
end

#entriesObject

Returns the value of attribute entries.



43
44
45
# File 'lib/rfeedparser/expat_parser.rb', line 43

def entries
  @entries
end

#excObject

Returns the value of attribute exc.



43
44
45
# File 'lib/rfeedparser/expat_parser.rb', line 43

def exc
  @exc
end

#feeddataObject

Returns the value of attribute feeddata.



43
44
45
# File 'lib/rfeedparser/expat_parser.rb', line 43

def feeddata
  @feeddata
end

Instance Method Details

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



97
98
99
100
# File 'lib/rfeedparser/expat_parser.rb', line 97

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

#comment(comment) ⇒ Object



119
120
121
# File 'lib/rfeedparser/expat_parser.rb', line 119

def comment(comment)
  handle_comment(comment)
end

#endElement(name) ⇒ Object



108
109
110
111
112
113
114
115
116
117
# File 'lib/rfeedparser/expat_parser.rb', line 108

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



76
77
# File 'lib/rfeedparser/expat_parser.rb', line 76

def endNamespaceDecl(prefix)
end

#entityDecl(*foo) ⇒ Object



123
124
# File 'lib/rfeedparser/expat_parser.rb', line 123

def entityDecl(*foo)
end

#error(exc) ⇒ Object



129
130
131
132
# File 'lib/rfeedparser/expat_parser.rb', line 129

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

#fatalError(exc) ⇒ Object



134
135
136
137
# File 'lib/rfeedparser/expat_parser.rb', line 134

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

#getAttrs(attrs) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/rfeedparser/expat_parser.rb', line 56

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

#getPosObject



52
53
54
# File 'lib/rfeedparser/expat_parser.rb', line 52

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

#setDocumentLocator(loc) ⇒ Object



64
65
66
# File 'lib/rfeedparser/expat_parser.rb', line 64

def setDocumentLocator(loc)
  @locator = loc
end

#startCdata(content) ⇒ Object

Just in case.



104
105
106
# File 'lib/rfeedparser/expat_parser.rb', line 104

def startCdata(content)
  handle_data(content)
end

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



68
69
70
# File 'lib/rfeedparser/expat_parser.rb', line 68

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rfeedparser/expat_parser.rb', line 79

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



72
73
74
# File 'lib/rfeedparser/expat_parser.rb', line 72

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

#unparsedEntityDecl(*foo) ⇒ Object



126
127
# File 'lib/rfeedparser/expat_parser.rb', line 126

def unparsedEntityDecl(*foo)
end