Sha256: 3298a1cf516a1605fa852198f2aa2188c4af2718785f5532f247b70edfa96fd1

Contents?: true

Size: 1.57 KB

Versions: 10

Compression:

Stored size: 1.57 KB

Contents

begin
  require "xml/parser"
rescue LoadError
  require "xmlparser"
end

begin
  require "xml/encoding-ja"
rescue LoadError
  require "xmlencoding-ja"
  if defined?(Kconv)
    module XMLEncoding_ja
      class SJISHandler
        include Kconv
      end
    end
  end
end

module XML
  class Parser
    unless defined?(Error)
      Error = ::XMLParserError
    end
  end
end

module RSS
  
  class REXMLLikeXMLParser < ::XML::Parser
    
    include ::XML::Encoding_ja

    def listener=(listener)
      @listener = listener
    end

    def startElement(name, attrs)
      @listener.tag_start(name, attrs)
    end
    
    def endElement(name)
      @listener.tag_end(name)
    end

    def character(data)
      @listener.text(data)
    end

    def xmlDecl(version, encoding, standalone)
      @listener.xmldecl(version, encoding, standalone == 1)
    end

    def processingInstruction(target, content)
      @listener.instruction(target, content)
    end

  end

  class XMLParserParser < BaseParser

    class << self
      def listener
        XMLParserListener
      end
    end
    
    private
    def _parse
      begin
        parser = REXMLLikeXMLParser.new
        parser.listener = @listener
        parser.parse(@rss)
      rescue ::XML::Parser::Error => e
        raise NotWellFormedError.new(parser.line){e.message}
      end
    end
    
  end
  
  class XMLParserListener < BaseListener

    include ListenerMixin
    
    def xmldecl(version, encoding, standalone)
      super
      # Encoding is converted to UTF-8 when XMLParser parses XML.
      @encoding = 'UTF-8'
    end

  end

end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
rubysl-rss-1.0.0 lib/rss/xmlparser.rb
ruby_on_ruby-0.0.1 vendor/javascripts/emscripted-ruby/lib/rss/xmlparser.rb
shoesgem-0.1514.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1480.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1469.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1430.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1429.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1428.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1426.0 shoes/ruby/lib/rss/xmlparser.rb
shoesgem-0.1424.0 shoes/ruby/lib/rss/xmlparser.rb