'Generates the content.xml file
Always written as a bytestream in UTF-8 encoding'

def contentxml(self):

    xml = StringIO()
    xml.write(_XMLPROLOGUE)
    x = DocumentContent()
    x.write_open_tag(0, xml)
    if self.scripts.hasChildNodes():
        self.scripts.toXml(1, xml)
    if self.fontfacedecls.hasChildNodes():
        self.fontfacedecls.toXml(1, xml)
    a = AutomaticStyles()
    stylelist = self._used_auto_styles([self.styles, self.automaticstyles, self.body])
    if (len(stylelist) > 0):
        a.write_open_tag(1, xml)
        for s in stylelist:
            s.toXml(2, xml)
        a.write_close_tag(1, xml)
    else:
        a.toXml(1, xml)
    self.body.toXml(1, xml)
    x.write_close_tag(0, xml)
    return xml.getvalue()
