module TDParser::XMLParser
Public Instance Methods
any_node(&)
click to toggle source
# File lib/tdparser/xml.rb, line 159 def any_node(&) (element(&) | doctype(&) | text | pi | cdata | comment | xmldecl | externalentity | elementdecl | entitydecl | attlistdecl | notationdecl) >> proc { |x| x[2] } end
attlistdecl(_decl = String)
click to toggle source
# File lib/tdparser/xml.rb, line 147 def attlistdecl(_decl = String) token(XArray[:attlistdecl]) >> proc do |x| REXML::AttlistDecl.new(x[0][1..]) end end
cdata(match = String)
click to toggle source
# File lib/tdparser/xml.rb, line 91 def cdata(match = String) token(XArray[:cdata, match]) >> proc do |x| REXML::CData.new(x[0][1]) end end
comment(match = String)
click to toggle source
# File lib/tdparser/xml.rb, line 97 def comment(match = String) token(XArray[:comment, match]) >> proc do |x| REXML::Comment.new(x[0][1]) end end
doctype(name = String, &inner)
click to toggle source
# File lib/tdparser/xml.rb, line 117 def doctype(name = String, &inner) crule = if inner inner.call | empty else empty end (start_doctype(name) - crule - end_doctype) >> proc do |x| node = REXML::DocType.new(x[0][1..]) [node, x[1]] end end
dom_constructor(&act)
click to toggle source
# File lib/tdparser/xml.rb, line 165 def dom_constructor(&act) proc do |x| node = x[0][0] child = x[0][1] if child.is_a?(Array) child.each { |c| node.add(c) } else node.add(child) end if act act[node] else node end end end
element(elem = String, &inner)
click to toggle source
# File lib/tdparser/xml.rb, line 63 def element(elem = String, &inner) crule = if inner inner.call | empty else empty end (start_element(elem) - crule - end_element(elem)) >> proc do |x| name = x[0][1] attrs = x[0][2] node = REXML::Element.new node.name = name node.attributes.merge!(attrs) [node, x[1]] end end
elementdecl(elem = String)
click to toggle source
# File lib/tdparser/xml.rb, line 135 def elementdecl(elem = String) token(XArray[:elementdecl, elem]) >> proc do |x| REXML::ElementDecl.new(x[0][1]) end end
end_doctype()
click to toggle source
# File lib/tdparser/xml.rb, line 113 def end_doctype token(XArray[:end_doctype]) end
end_element(name = String)
click to toggle source
# File lib/tdparser/xml.rb, line 59 def end_element(name = String) token(XArray[:end_element, name]) end
entitydecl(_entity = String)
click to toggle source
# File lib/tdparser/xml.rb, line 141 def entitydecl(_entity = String) token(XArray[:entitydecl, elem]) >> proc do |x| REXML::Entity.new(x[0]) end end
externalentity(entity = String)
click to toggle source
# File lib/tdparser/xml.rb, line 129 def externalentity(entity = String) token(XArray[:externalentity, entity]) >> proc do |x| REXML::ExternalEntity.new(x[0][1]) end end
notationdecl(_decl = String)
click to toggle source
# File lib/tdparser/xml.rb, line 153 def notationdecl(_decl = String) token(XArray[:notationdecl]) >> proc do |x| REXML::NotationDecl.new(*x[0][1..]) end end
pi()
click to toggle source
# File lib/tdparser/xml.rb, line 85 def pi token(XArray[:processing_instruction, String, String]) >> proc do |x| REXML::Instruction.new(x[0][1], x[0][2]) end end
start_doctype(name = String)
click to toggle source
# File lib/tdparser/xml.rb, line 109 def start_doctype(name = String) token(XArray[:start_doctype, name]) end
start_element(name = String)
click to toggle source
# File lib/tdparser/xml.rb, line 55 def start_element(name = String) token(XArray[:start_element, name, Hash]) end
text(match = String)
click to toggle source
# File lib/tdparser/xml.rb, line 79 def text(match = String) token(XArray[:text, match]) >> proc do |x| REXML::Text.new(x[0][1]) end end
xmldecl()
click to toggle source
# File lib/tdparser/xml.rb, line 103 def xmldecl token(XArray[:xmldecl]) >> proc do |x| REXML::XMLDecl.new(x[0][1], x[0][2], x[0][3]) end end