'Returns an XML representation of this entity. Atom and gd:namespace
properties are converted to XML according to their respective schemas. For
more information, see:
http://www.atomenabled.org/developers/syndication/
http://code.google.com/apis/gdata/common-elements.html
This is *not* optimized. It shouldn\'t be used anywhere near code that\'s
performance-critical.'

def ToXml(self):

    xml = (u'<entity    kind=%s' % saxutils.quoteattr(self.kind()))
    if self.__key.has_id_or_name():
        xml += ('    key=%s' % saxutils.quoteattr(str(self.__key)))
    xml += '>'
    if self.__key.has_id_or_name():
        xml += ('\n        <key>%s</key>' % self.__key.ToTagUri())
    properties = self.keys()
    if properties:
        properties.sort()
        xml += ('\n        ' + '\n        '.join(self._PropertiesToXml(properties)))
    xml += '\n</entity>\n'
    return xml
