This method adds loc-group content to an XML
parent node.
# - - - L o c G r o u p . w r i t e N o d e
def writeNode(self, node):
"""Add loc-group content to node.
"""
The loc and gps attributes are
optional; add them only if they are not None.
#-- 1 --
# [ if self.locCode ->
# node := node with an rnc.LOC_A attribute added
# from self.locCode
# else -> I ]
if self.loc:
node.attrib[rnc.LOC_A] = self.loc.code
#-- 2 --
# [ if self.gps ->
# node := node with an rnc.GPS_A attribute added
# from self.gps
# else -> I ]
if self.gps:
node.attrib[rnc.GPS_A] = self.gps
The loc-detail content is a child element, not an
attribute. The .locDetail attribute is a Narrative instance. For the method that adds the narrative content, see Section 18.6, “Narrative.writeNode(): Write as XML”.
#-- 3 --
# [ if self.locDetail ->
# node := node with a new child rnc.LOC_DETAIL_N
# node added made from self.locDetail ]
if self.locDetail:
detail = et.SubElement(node, rnc.LOC_DETAIL_N)
self.locDetail.writeNode(detail)