summaryrefslogtreecommitdiff
path: root/lib/rss/1.0.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-21 09:20:47 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-21 09:20:47 +0000
commit7ead69e5b3a2b09878037f11a7dda59ae402ccbf (patch)
treef7a422e5983f2c475c831e5d70987437eb77fa69 /lib/rss/1.0.rb
parent2639d6dc809a3f78c96543c839d72d05e6e90ca7 (diff)
downloadruby-7ead69e5b3a2b09878037f11a7dda59ae402ccbf.tar.gz
* test/rss/test_xml-stylesheet.rb: added tests for xml-stylesheet.
* lib/rss/xml-stylesheet.rb: added xml-stylesheet parsing function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rss/1.0.rb')
-rw-r--r--lib/rss/1.0.rb50
1 files changed, 19 insertions, 31 deletions
diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb
index cd645eedb3..6c33f1695d 100644
--- a/lib/rss/1.0.rb
+++ b/lib/rss/1.0.rb
@@ -10,6 +10,8 @@ module RSS
class RDF < Element
include RSS10
+ include RootElementMixin
+ include XMLStyleSheetMixin
class << self
@@ -45,23 +47,13 @@ module RSS
attr_accessor :rss_version, :version, :encoding, :standalone
def initialize(version=nil, encoding=nil, standalone=nil)
- super()
- @rss_version = '1.0'
- @version = version || '1.0'
- @encoding = encoding
- @standalone = standalone
- @output_encoding = nil
- end
-
- def output_encoding=(enc)
- @output_encoding = enc
- self.converter = Converter.new(@output_encoding, @encoding)
+ super('1.0', version, encoding, standalone)
end
def to_s(convert=true)
rv = <<-EORDF
#{xmldecl}
-<#{PREFIX}:RDF#{ns_declaration}>
+#{xml_stylesheet_pi}<#{PREFIX}:RDF#{ns_declaration}>
#{channel_element(false)}
#{image_element(false)}
#{item_elements(false)}
@@ -74,25 +66,6 @@ EORDF
end
private
- def xmldecl
- rv = %Q[<?xml version="#{@version}"]
- if @output_encoding or @encoding
- rv << %Q[ encoding="#{@output_encoding or @encoding}"]
- end
- rv << %Q[ standalone="#{@standalone}"] if @standalone
- rv << '?>'
- rv
- end
-
- def ns_declaration
- rv = ''
- self.class::NSPOOL.each do |prefix, uri|
- prefix = ":#{prefix}" unless prefix.empty?
- rv << %Q|\n\txmlns#{prefix}="#{html_escape(uri)}"|
- end
- rv
- end
-
def rdf_validate(tags)
_validate(tags, [])
end
@@ -647,4 +620,19 @@ EOT
BaseListener.install_get_text_element(x, URI, "#{x}=")
end
+ module ListenerMixin
+ private
+ def start_RDF(tag_name, prefix, attrs, ns)
+ check_ns(tag_name, prefix, ns, RDF::URI)
+
+ @rss = RDF.new(@version, @encoding, @standalone)
+ @rss.do_validate = @do_validate
+ @rss.xml_stylesheets = @xml_stylesheets
+ @last_element = @rss
+ @proc_stack.push Proc.new { |text, tags|
+ @rss.validate_for_stream(tags) if @do_validate
+ }
+ end
+ end
+
end