code: def write_xml(self, root):
          
  
          if not self.extended:
              try:
                  source_element = utils.create_xml_element(root, 'source',
                                                            dict(name=self['Source_Name'],
                                                                 type='PointSource'))
              except TypeError as msg:
                  print (self['Source_Name'], self)
                  raise TypeError(msg)
  
              spat_el = ElementTree.SubElement(source_element, 'spatialModel')
              spat_el.set('type', 'SkyDirFunction')
  
          elif self['SpatialType'] == 'SpatialMap':
              source_element = utils.create_xml_element(root, 'source',
                                                        dict(name=self['Source_Name'],
                                                             type='DiffuseSource'))
  
              filename = utils.path_to_xmlpath(self['Spatial_Filename'])
              spat_el = utils.create_xml_element(source_element, 'spatialModel',
                                                 dict(map_based_integral='True',
                                                      type='SpatialMap',
                                                      file=filename))
          else:
              source_element = utils.create_xml_element(root, 'source',
                                                        dict(name=self['Source_Name'],
                                                             type='DiffuseSource'))
              spat_el = utils.create_xml_element(source_element, 'spatialModel',
                                                 dict(type=self['SpatialType']))
  
          for k, v in self.spatial_pars.items():
              utils.create_xml_element(spat_el, 'parameter', v)
  
          el = ElementTree.SubElement(source_element, 'spectrum')
  
          stype = self['SpectrumType'].strip()
          el.set('type', stype)
  
          if self['Spectrum_Filename'] is not None:
              filename = utils.path_to_xmlpath(self['Spectrum_Filename'])
              el.set('file', filename)
  
          for k, v in self.spectral_pars.items():
              utils.create_xml_element(el, 'parameter', v)
docs: Write this source to an XML node.