Next / Previous / Contents / Shipman's homepage

16.3. Rank.writeXML(): Generate XML

nomcompile3
# - - -   R a n k . w r i t e X M L

    def writeXML ( self, parent ):
        '''Generate an XML representation of self.
        '''

The XML for a rank has four attributes plus content:

nomcompile3
        #-- 1 --
        # [ attributes  :=  a dictionary of the attribute names
        #                   and values for self ]
        attributes = {
            rnc.CODE_A: self.code,
            rnc.DIGITS_A: str(self.keyLen),
            rnc.DEPTH_A: str(self.depth) }
        if not self.required:
            attributes[rnc.OPTIONAL_A] = '1'

        #-- 2 --
        # [ parent  :=  parent with a new rnc.RANK_N element added
        #               with attributes (attributes) and content
        #               self.name ]
        parent.append ( E ( rnc.RANK_N, attributes, self.name ) )