As with the Element constructor,
the first argument to this constructor is the parent node, whose .doc attribute is a DOM Document
node that carries the .createTextNode()
factory method we need to create a DOM Text node.
# - - - T e x t . _ _ i n i t _ _ - - -
def __init__ ( self, parent, content ):
"""Constructor for Text
[ parent is an Element object ->
parent := parent with a new text node added with
text=content
return a new Text object representing that text ]
"""
#-- 1 --
# [ parent is an Element ->
# self.node := a new DOM Text node with content=content ]
self.node = parent.doc.node.createTextNode ( content )
Next, we attach the newly constructed DOM Text node to its parent DOM node.
#-- 2 --
# [ parent := parent with self.node added as its next or
# only child ]
parent.node.appendChild ( self.node )