Class Amrita::Listener
In: lib/amrita/xml.rb
Parent: Object

Methods

doctype   new   pop   push   result   tag_end   tag_start   text   top   xmldecl  

Included Modules

Amrita REXML::StreamListener

Public Class methods

[Source]

# File lib/amrita/xml.rb, line 40
    def initialize(&block)
      @stack = [ Null ]
                        @block = block
    end

Public Instance methods

[Source]

# File lib/amrita/xml.rb, line 89
    def doctype(name, pub_sys, long_name, uri)
      s = SpecialElement.new('!', %Q[DOCTYPE #{name} #{pub_sys} #{long_name} #{uri}])
      push(pop + s)
    end

[Source]

# File lib/amrita/xml.rb, line 49
    def pop
      @stack.shift
    end

[Source]

# File lib/amrita/xml.rb, line 45
    def push(element)
      @stack.unshift element
    end

[Source]

# File lib/amrita/xml.rb, line 57
    def result
      raise "can't happen @stack.size=#{@stack.size}" unless @stack.size == 1
      top
    end

[Source]

# File lib/amrita/xml.rb, line 71
    def tag_end(name)
      body = pop
      element = pop
      element.init_body { body }
      push(pop + element)
    end

[Source]

# File lib/amrita/xml.rb, line 62
    def tag_start(name, attrs)
      a = attrs.collect { |key, val|
        Attr.new(key, convert(val))
      }
                        t = @block.call(e(name, *a))
      push t
      push Null
    end

[Source]

# File lib/amrita/xml.rb, line 78
    def text(text)
      push(pop + TextElement.new(convert(text)))
    end

[Source]

# File lib/amrita/xml.rb, line 53
    def top
     @stack.first
    end

[Source]

# File lib/amrita/xml.rb, line 82
    def xmldecl(version, encoding, standalone)
      text = %Q[xml version="#{version}"]
      text += %Q[ encoding="#{encoding}"] if encoding
      s = SpecialElement.new('?', text)
      push(pop + s)
    end

[Validate]