## -*- Ruby -*- ## XML::DOM ## 1998-2001 by yoshidam ## require 'xml/dom2/characterdata' require 'xml/dom2/domexception' module XML module DOM =begin == Class XML::DOM::Text === superclass Node =end class Text" ret << ">" else ret << c end end ret ## XML.charRef(@value) end =begin --- Text#dump(depth = 0) dumps the Text. =end def dump(depth = 0) print ' ' * depth * 2 print "#{@value.inspect}\n" end =begin --- Text#splitText(offset) [DOM] breaks this Text node into two Text nodes at the specified offset. =end ## [DOM] def splitText(offset) if offset > @value.length || offset < 0 raise DOMException.new(DOMException::INDEX_SIZE_ERR) end newText = @value[offset, @value.length] newNode = Text.new(newText) if !self.parentNode.nil? self.parentNode.insertAfter(newNode, self) end @value[offset, @value.length] = "" newNode end =begin --- Text#trim(preserve = false) trim extra whitespaces. =end def trim(preserve = false) if !preserve @value.sub!(/\A\s*([\s\S]*?)\s*\Z/, "\\1") return @value end nil end end end end