Class REXML::Parsers::PullEvent
In: lib/rexml/parsers/pullparser.rb
Parent: Object

A parsing event. The contents of the event are accessed as an +Array?, and the type is given either by the …? methods, or by accessing the type accessor. The contents of this object vary from event to event, but are identical to the arguments passed to +StreamListener+s for each event.

Methods

Public Class methods

The type of this event. Will be one of :tag_start, :tag_end, :text, :processing_instruction, :comment, :doctype, :attlistdecl, :entitydecl, :notationdecl, :entity, :cdata, :xmldecl, or :error.

[Source]

    # File lib/rexml/parsers/pullparser.rb, line 94
94:       def initialize(arg)
95:         @contents = arg
96:       end

Public Instance methods

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 98
 98:       def []( start, endd=nil)
 99:         if start.kind_of? Range
100:           @contents.slice( start.begin+1 .. start.end )
101:         elsif start.kind_of? Numeric
102:           if endd.nil?
103:             @contents.slice( start+1 )
104:           else
105:             @contents.slice( start+1, endd )
106:           end
107:         else
108:           raise "Illegal argument #{start.inspect} (#{start.class})"
109:         end
110:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 147
147:       def attlistdecl?
148:         @contents[0] == :attlistdecl
149:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 178
178:       def cdata?
179:         @contents[0] == :cdata
180:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 137
137:       def comment?
138:         @contents[0] == :comment
139:       end

Content: [ String name, String pub_sys, String long_name, String uri ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 142
142:       def doctype?
143:         @contents[0] == :start_doctype
144:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 152
152:       def elementdecl?
153:         @contents[0] == :elementdecl
154:       end

Content: [ String tag_name ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 122
122:       def end_element?
123:         @contents[0] == :end_element
124:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 173
173:       def entity?
174:         @contents[0] == :entity
175:       end

Due to the wonders of DTDs, an entity declaration can be just about anything. There‘s no way to normalize it; you‘ll have to interpret the content yourself. However, the following is true:

  • If the entity declaration is an internal entity: [ String name, String value ]

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 163
163:       def entitydecl?
164:         @contents[0] == :entitydecl
165:       end

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 187
187:       def error?
188:         @contents[0] == :error
189:       end

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 112
112:       def event_type
113:         @contents[0]
114:       end

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 191
191:       def inspect
192:         @contents[0].to_s + ": " + @contents[1..-1].inspect
193:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 132
132:       def instruction?
133:         @contents[0] == :processing_instruction
134:       end

Content: [ String text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 168
168:       def notationdecl?
169:         @contents[0] == :notationdecl
170:       end

Content: [ String tag_name, Hash attributes ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 117
117:       def start_element?
118:         @contents[0] == :start_element
119:       end

Content: [ String raw_text, String unnormalized_text ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 127
127:       def text?
128:         @contents[0] == :text
129:       end

Content: [ String version, String encoding, String standalone ]

[Source]

     # File lib/rexml/parsers/pullparser.rb, line 183
183:       def xmldecl?
184:         @contents[0] == :xmldecl
185:       end

[Validate]