Next / Previous / Contents / Shipman's homepage

13.3. Sighting.writeNode(): Translate to XML

This method converts self to a new floc node.

birdnotes.py
# - - -   S i g h t i n g . w r i t e N o d e

    def writeNode(self, formNode):
        """Convert self to XML.

          [ formNode is an et.Element ->
              formNode  +:=  a new rnc.FLOC_N child made from self ]
        """

First, attach the new node.

birdnotes.py
        #-- 1 --
        # [ formNode  :=  formNode with a new rnc.FLOC_N child added
        #   flocNode  :=  that new child ]
        flocNode = et.SubElement(formNode, rnc.FLOC_N)

There are three content groups, each with a corresponding method that translates it to XML.

birdnotes.py
        #-- 2 --
        # [ if self.ageSexGroup ->
        #     flocNode  +:=  age-sex-group content from
        #                    self.ageSexGroup
        #   else -> I ]
        if  self.ageSexGroup:
            self.ageSexGroup.writeNode(flocNode)

        #-- 3 --
        # [ simile ]
        if  self.locGroup:
            self.locGroup.writeNode(flocNode)

        #-- 4 --
        if  self.sightNotes:
            self.sightNotes.writeNode(flocNode)