Sha256: ca138a89c9a51b380f9b01141ed15f54e7382d78c97c20fde59d220b1928771b
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
# Copyright (C) 2007-2008 Annas Al Maleh # Licensed under the LGPL. See /COPYING.LGPL for more details. require File.dirname(__FILE__) + "/node_visitor" class XmlVisitor < NodeVisitor attr_reader :document def initialize @document = "" end def process_before_children(node) if (node.is_a?(String)) @document << node return end begin_open_tag(node) append_attributes(node) if node.attributes end_open_tag(node) end def process_after_children(node) return if (node.is_a?(String)) append_close_tag(node) end def begin_open_tag(node) @document << "<" @document << "#{node.name_space.name}:" if node.name_space @document << node.name end def end_open_tag(node) if (node.contents) @document << ">" else @document << " " if node.attributes.keys.size > 0 @document << "/>" end end def append_close_tag(node) if (node.contents) @document << "</" @document << "#{node.name_space.name}:" if node.name_space @document << "#{node.name}>" end end def append_attributes(node) puts "Take 3" p node.attributes node.attributes.each_key do |attribute| attribute_name = attribute attribute_name = "#{attribute.name_space.name}:#{attribute.name}" if attribute.is_a?(Node) @document << " #{attribute_name}=\"#{node.attributes[attribute]}\"" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glimmer-0.1.0.0 | src/xml_command_handlers/models/xml_visitor.rb |