diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-21 09:20:47 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-21 09:20:47 +0000 |
commit | 7ead69e5b3a2b09878037f11a7dda59ae402ccbf (patch) | |
tree | f7a422e5983f2c475c831e5d70987437eb77fa69 /lib/rss/rss.rb | |
parent | 2639d6dc809a3f78c96543c839d72d05e6e90ca7 (diff) | |
download | ruby-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/rss.rb')
-rw-r--r-- | lib/rss/rss.rb | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb index 6386ca3973..7ac1f42628 100644 --- a/lib/rss/rss.rb +++ b/lib/rss/rss.rb @@ -1,7 +1,9 @@ require "time" +require "English" require "rss/utils" require "rss/converter" +require "rss/xml-stylesheet" module RSS @@ -365,7 +367,6 @@ EOC def initialize(do_validate=true) @converter = nil - @output_encoding = nil @do_validate = do_validate initialize_variables end @@ -561,4 +562,44 @@ EOC end + module RootElementMixin + + attr_reader :output_encoding + + def initialize(rss_version, version=nil, encoding=nil, standalone=nil) + super() + @rss_version = rss_version + @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) + 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 + + end + end |