Class: XmlEasy::EasyListener
- Inherits:
-
Object
- Object
- XmlEasy::EasyListener
- Includes:
- REXML::StreamListener
- Defined in:
- lib/xml_easy.rb
Instance Method Summary collapse
- #attlistdecl(elm_name, attrs, content) ⇒ Object
- #cdata(content) ⇒ Object
- #comment(content) ⇒ Object
- #doctype(name, pub_sys, long_name, uri) ⇒ Object
- #doctype_end ⇒ Object
- #elementdecl(content) ⇒ Object
- #entity(content) ⇒ Object
- #entitydecl(content) ⇒ Object
-
#initialize(doc) ⇒ EasyListener
constructor
A new instance of EasyListener.
- #instruction(name, inst) ⇒ Object
- #notationdecl(content) ⇒ Object
- #tag_end(name) ⇒ Object
- #tag_start(name, attrs) ⇒ Object
- #text(content) ⇒ Object
- #xmldecl(version, encoding, standalone) ⇒ Object
Constructor Details
#initialize(doc) ⇒ EasyListener
Returns a new instance of EasyListener.
32 33 34 35 |
# File 'lib/xml_easy.rb', line 32 def initialize(doc) @doc = doc @current = doc.root end |
Instance Method Details
#attlistdecl(elm_name, attrs, content) ⇒ Object
37 |
# File 'lib/xml_easy.rb', line 37 def attlistdecl(elm_name, attrs, content); end |
#cdata(content) ⇒ Object
76 77 78 |
# File 'lib/xml_easy.rb', line 76 def cdata(content) #TODO end |
#comment(content) ⇒ Object
38 |
# File 'lib/xml_easy.rb', line 38 def comment(content); end |
#doctype(name, pub_sys, long_name, uri) ⇒ Object
43 |
# File 'lib/xml_easy.rb', line 43 def doctype(name, pub_sys, long_name, uri); end |
#doctype_end ⇒ Object
45 |
# File 'lib/xml_easy.rb', line 45 def doctype_end; end |
#elementdecl(content) ⇒ Object
39 |
# File 'lib/xml_easy.rb', line 39 def elementdecl(content); end |
#entity(content) ⇒ Object
40 |
# File 'lib/xml_easy.rb', line 40 def entity(content); end |
#entitydecl(content) ⇒ Object
44 |
# File 'lib/xml_easy.rb', line 44 def entitydecl(content); end |
#instruction(name, inst) ⇒ Object
41 |
# File 'lib/xml_easy.rb', line 41 def instruction(name, inst); end |
#notationdecl(content) ⇒ Object
42 |
# File 'lib/xml_easy.rb', line 42 def notationdecl(content); end |
#tag_end(name) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/xml_easy.rb', line 64 def tag_end(name) if @current.name == name.to_sym @current = @current.parent else raise RuntimeError.new("unmatch end-tag: #{name.inspect}") end end |
#tag_start(name, attrs) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/xml_easy.rb', line 57 def tag_start(name, attrs) element = Element.new name attrs.each{|k, v| element[k] = v.gsub('"', '"').inspect} @current << element @current = element end |
#text(content) ⇒ Object
72 73 74 |
# File 'lib/xml_easy.rb', line 72 def text(content) @current.body = content end |
#xmldecl(version, encoding, standalone) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/xml_easy.rb', line 47 def xmldecl(version, encoding, standalone) @doc.xml_dec = "<?xml#{ version ? " version='#{version}'" : '' }#{ encoding ? " encoding='#{encoding}'" : '' }#{ standalone ? " standalone='#{standalone}'" : '' }?>" end |