Next / Previous / Contents / Shipman's homepage

18.6. Narrative.writeNode(): Write as XML

This method attaches one or more rnc.PARA_N elements to the given parent node.
# - - -   N a r r a t i v e . w r i t e N o d e

    def writeNode(self, parent):
        """Output self's content as XML.

Normally the content is a sequence of Paragraph instances. In that case, all we need to do is to call the .writeNode() method for each of those instances. See Section 19.4, “Paragraph.writeNode(): Write as XML”.

When the instance's content is only a single para, we don't need to wrap the output in a para element, so we bypass the addition of this node and directly use Section 19.5, “Paragraph.writeContent(): Write the content of a paragraph”.
        #-- 1 --
        if  len(self._paraList) > 1:
            #-- 1.1 --
            # [ parent  :=  parent with XML added for each element
            #               of self._paraList ]
            for  para in self._paraList:
        elif  len(self._paraList) == 1:
            #-- 1.2 --
            # [ parent  :=  parent with XML added for the first
            #               element of self._paraList ]
            solePara = self._paraList[0]