Class: Kwaff::Rexml::Parser
Overview
Parse Kwaff string and return REXML::Document
ex.
kwaff_str = File.open('file.kwaff') { |f| f.read }
parser = Kwaff::Rexml::Parser.new(kwaff_str)
rexml_document = parser.parse_document()
Instance Attribute Summary
Attributes inherited from Parser
#index, #lines, #newline
Instance Method Summary
collapse
Methods inherited from Parser
#initialize, #parse_cdata, #parse_comment, #parse_document, #parse_element, #parse_node_list, #parse_text, #reset, #spclen
Constructor Details
This class inherits a constructor from Kwaff::Parser
Instance Method Details
138
139
140
|
# File 'lib/kwaff/rexml.rb', line 138
def (str)
return REXML::Comment.new(str)
end
|
#create_document(headers, root) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/kwaff/rexml.rb', line 103
def create_document(, root)
Kwaff::assert() unless root.is_a?(REXML::Element)
s = ''
s << '<?xml version="' << ([:xmlversion] || '1.0')
if [:encoding]
s << ' encoding="' << [:encoding] << '"'
end
s << "?>\n"
s << [:doctype].to_s if [:doctype]
rexml_document = REXML::Document.new(s)
rexml_document.add(root)
return rexml_document
end
|
#create_element(tag, children, attrs) ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/kwaff/rexml.rb', line 126
def create_element(tag, children, attrs)
rexml_element = REXML::Element.new
rexml_element.name = tag
attrs.each do |aname, avalue|
rexml_element.add_attribute(aname, avalue)
end if attrs
children.each do |child|
rexml_element.add(child)
end if children
return rexml_element
end
|
#create_text(str, flag_escape = true) ⇒ Object
142
143
144
|
# File 'lib/kwaff/rexml.rb', line 142
def create_text(str, flag_escape=true)
return flag_escape ? REXML::Text.new(str) : REXML::CData.new(str)
end
|
#set_node_option(node, name, value) ⇒ Object
146
147
148
|
# File 'lib/kwaff/rexml.rb', line 146
def set_node_option(node, name, value)
end
|