mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
* lib/rss/parser.rb, lib/rss/1.0.rb: accepted rdf:resource or
resource attribute in rdf:li. * test/rss/test_parser.rb: added test for above change. * lib/rss/dublincore.rb: reverted style. * lib/rss/xmlparser.rb: normalized XMLParser class hierarchy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4ded52b623
commit
8dfa6fb0a8
9 changed files with 84 additions and 38 deletions
|
@ -150,7 +150,7 @@ EOT
|
|||
end
|
||||
|
||||
[
|
||||
["resource", nil, true]
|
||||
["resource", [URI, nil], true]
|
||||
].each do |name, uri, required|
|
||||
install_get_attribute(name, uri, required)
|
||||
end
|
||||
|
|
|
@ -46,11 +46,11 @@ module RSS
|
|||
# For backward compatibility
|
||||
DublincoreModel = DublinCoreModel
|
||||
|
||||
class RDF < Element
|
||||
class Channel < Element; include DublinCoreModel; end
|
||||
class Image < Element; include DublinCoreModel; end
|
||||
class Item < Element; include DublinCoreModel; end
|
||||
class Textinput < Element; include DublinCoreModel; end
|
||||
class RDF
|
||||
class Channel; include DublinCoreModel; end
|
||||
class Image; include DublinCoreModel; end
|
||||
class Item; include DublinCoreModel; end
|
||||
class Textinput; include DublinCoreModel; end
|
||||
end
|
||||
|
||||
prefix_size = DC_PREFIX.size + 1
|
||||
|
|
|
@ -260,19 +260,18 @@ module RSS
|
|||
def start_else_element(local, prefix, attrs, ns)
|
||||
class_name = local[0,1].upcase << local[1..-1]
|
||||
current_class = @last_element.class
|
||||
begin
|
||||
# if current_class.const_defined?(class_name)
|
||||
# begin
|
||||
if current_class.constants.include?(class_name)
|
||||
next_class = current_class.const_get(class_name)
|
||||
start_have_something_element(local, prefix, attrs, ns, next_class)
|
||||
rescue NameError
|
||||
# else
|
||||
# rescue NameError
|
||||
else
|
||||
if @ignore_unknown_element
|
||||
@proc_stack.push(nil)
|
||||
else
|
||||
parent = "ROOT ELEMENT???"
|
||||
begin
|
||||
parent = current_class::TAG_NAME
|
||||
rescue NameError
|
||||
if current_class.const_defined?("TAG_NAME")
|
||||
parent = current_class.const_get("TAG_NAME")
|
||||
end
|
||||
raise NotExceptedTagError.new(local, parent)
|
||||
end
|
||||
|
@ -317,14 +316,18 @@ module RSS
|
|||
|
||||
klass.get_attributes.each do |a_name, a_uri, required|
|
||||
|
||||
if a_uri
|
||||
if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
|
||||
a_uri = [a_uri]
|
||||
end
|
||||
unless a_uri == [nil]
|
||||
for prefix, uri in ns
|
||||
if uri == a_uri
|
||||
if a_uri.include?(uri)
|
||||
val = attrs["#{prefix}:#{a_name}"]
|
||||
break if val
|
||||
end
|
||||
end
|
||||
else
|
||||
end
|
||||
if val.nil? and a_uri.include?(nil)
|
||||
val = attrs[a_name]
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "time"
|
||||
|
||||
class Time
|
||||
class << Time
|
||||
class << self
|
||||
unless respond_to?(:w3cdtf)
|
||||
def w3cdtf(date)
|
||||
if /\A\s*
|
||||
|
@ -510,11 +510,8 @@ EOC
|
|||
|
||||
if not_shift
|
||||
not_shift = false
|
||||
else
|
||||
begin
|
||||
tag = tags.shift
|
||||
rescue NameError
|
||||
end
|
||||
elsif tags
|
||||
tag = tags.shift
|
||||
end
|
||||
|
||||
if DEBUG
|
||||
|
@ -551,11 +548,9 @@ EOC
|
|||
end
|
||||
else
|
||||
if elem[0] == tag
|
||||
begin
|
||||
if model[i+1][0] != elem[0] and tags.first == elem[0]
|
||||
raise TooMuchTagError.new(elem[0], tag_name)
|
||||
end
|
||||
rescue NameError # for model[i+1][0] and tags.first
|
||||
if model[i+1] and model[i+1][0] != elem[0] and
|
||||
tags and tags.first == elem[0]
|
||||
raise TooMuchTagError.new(elem[0], tag_name)
|
||||
end
|
||||
else
|
||||
raise MissingTagError.new(elem[0], tag_name)
|
||||
|
|
|
@ -17,6 +17,14 @@ rescue LoadError
|
|||
end
|
||||
end
|
||||
|
||||
module XML
|
||||
class Parser
|
||||
unless defined?(Error)
|
||||
Error = ::XMLParserError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module RSS
|
||||
|
||||
class REXMLLikeXMLParser < ::XML::Parser
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue