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

Methods

cdata   comment   doctype   instruction   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 48
    def initialize
      @stack = [ Null ]
    end

Public Instance methods

override

[Source]

# File lib/amrita/xml.rb, line 102
    def cdata(content)
      push(pop + SpecialElement.new('![CDATA[', content))
    end

override

[Source]

# File lib/amrita/xml.rb, line 97
    def comment(comment)
      push(pop + SpecialElement.new('!--', comment))
    end

override

[Source]

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

override

[Source]

# File lib/amrita/xml.rb, line 92
    def instruction(name, instruction)
      push(pop + SpecialElement.new('?', name + instruction))
    end

[Source]

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

[Source]

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

[Source]

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

override

[Source]

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

override

[Source]

# File lib/amrita/xml.rb, line 70
    def tag_start(name, attrs)
      a = attrs.collect do |key, val|
        Attr.new(key, convert(val))
      end
      push e(name.intern, *a)
      push Null
    end

override

[Source]

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

[Source]

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

override

[Source]

# File lib/amrita/xml.rb, line 107
    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]