Sha256: ca4340215dab4f1e4cc4cf35bffc5210f7e70a972cae199f6eaed4a5c8a6e96a

Contents?: true

Size: 1.66 KB

Versions: 16

Compression:

Stored size: 1.66 KB

Contents

module Ox
  # A SAX style parse handler. The Ox::Sax handler class should be subclasses
  # and then used with the Ox.sax_parse() method. The Sax methods will then be
  # called as the file is parsed. This is best suited for very large files or
  # IO streams.<p/>
  # @example
  # 
  #  require 'ox'
  #
  #  class MySax < ::Ox::Sax
  #    def initialize()
  #      @element_name = []
  #    end
  #
  #    def start_element(name, attrs)
  #      @element_names << name
  #    end
  #  end
  #
  #  any = MySax.new()
  #  File.open('any.xml', 'r') do |f|
  #    Xml.sax_parse(any, f)
  #  end
  #
  # To make the desired methods active while parsing the desired method should
  # be made public in the subclasses. If the methods remain private they will
  # not be called during parsing.
  #
  #    def instruct(target); end
  #    def attr(name, value); end
  #    def doctype(value); end
  #    def comment(value); end
  #    def cdata(value); end
  #    def text(value); end
  #    def start_element(name); end
  #    def end_element(name); end
  #
  class Sax
    # Create a new instance of the Sax handler class.
    def initialize()
    end

    # To make the desired methods active while parsing the desired method
    # should be made public in the subclasses. If the methods remain private
    # they will not be called during parsing.
    private

    def instruct(target)
    end

    def attr(name, value)
    end

    def doctype(value)
    end

    def comment(value)
    end

    def cdata(value)
    end

    def text(value)
    end

    def start_element(name)
    end

    def end_element(name)
    end
    
    def error(message, line, column)
    end
    
  end # Sax
end # Ox

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ox-1.5.4 lib/ox/sax.rb
ox-1.5.3 lib/ox/sax.rb
ox-1.5.2 lib/ox/sax.rb
ox-1.5.1 lib/ox/sax.rb
ox-1.5.0 lib/ox/sax.rb
ox-1.4.6 lib/ox/sax.rb
ox-1.4.5 lib/ox/sax.rb
ox-1.4.4 lib/ox/sax.rb
ox-1.4.3 lib/ox/sax.rb
ox-1.4.2 lib/ox/sax.rb
ox-1.4.1 lib/ox/sax.rb
ox-1.4.0 lib/ox/sax.rb
ox-1.3.5 lib/ox/sax.rb
ox-1.3.4 lib/ox/sax.rb
ox-1.3.3 lib/ox/sax.rb
ox-1.3.2 lib/ox/sax.rb