class LANSA::XML::SAX2DOM
Attributes
document[R]
Public Class Methods
new(use_namespaces = true)
click to toggle source
# File xml/sax2dom.rb, line 13 def initialize use_namespaces = true @use_namespaces = use_namespaces @document = nil @stack = [] end
Public Instance Methods
cdata_block(s)
click to toggle source
# File xml/sax2dom.rb, line 79 def cdata_block s parent = @stack.last cdata = Nokogiri::XML::CDATA.new(@document, s) parent.add_child cdata end
characters(s)
click to toggle source
# File xml/sax2dom.rb, line 67 def characters s parent = @stack.last text = Nokogiri::XML::Text.new(s, @document) parent.add_child text end
clear()
click to toggle source
# File xml/sax2dom.rb, line 19 def clear @document = nil @stack.clear end
comment(s)
click to toggle source
# File xml/sax2dom.rb, line 73 def comment s parent = @stack.last comment = Nokogiri::XML::Comment.new(@document, s) parent.add_child comment end
end_document()
click to toggle source
# File xml/sax2dom.rb, line 32 def end_document @stack.pop end
end_element_namespace(*args)
click to toggle source
# File xml/sax2dom.rb, line 63 def end_element_namespace *args @stack.pop end
start_document()
click to toggle source
# File xml/sax2dom.rb, line 27 def start_document @document = Nokogiri::XML::Document.new @stack << @document end
start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
click to toggle source
# File xml/sax2dom.rb, line 36 def start_element_namespace name, attrs = [], prefix = nil, uri = nil, ns = [] name = prefixed_name(name, prefix) element = Nokogiri::XML::Element.new(name, @document) # Add namespaces to element ns.each do |n| element.add_namespace n.first, n.last end # Add attributes to element attrs.each do |attr| aname = prefixed_name(attr.localname, attr.prefix) element[aname] = attr.value end parent = @stack.last parent.add_child(element) @stack << element end
xmldecl(version, encoding, standalone)
click to toggle source
# File xml/sax2dom.rb, line 24 def xmldecl version, encoding, standalone end