Esempio n. 1
0
 def contentxml(self):
     """ Generates the content.xml file
         Always written as a bytestream in UTF-8 encoding
     """
     xml = PolyglotBytesIO()
     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()
Esempio n. 2
0
 def __manifestxml(self):
     """ Generates the manifest.xml file
         The self.manifest isn't avaible unless the document is being saved
     """
     xml=PolyglotBytesIO()
     xml.write(_XMLPROLOGUE)
     self.manifest.toXml(0,xml)
     return xml.getvalue()
Esempio n. 3
0
 def __manifestxml(self):
     """ Generates the manifest.xml file
         The self.manifest isn't avaible unless the document is being saved
     """
     xml=PolyglotBytesIO()
     xml.write(_XMLPROLOGUE)
     self.manifest.toXml(0,xml)
     return xml.getvalue()
Esempio n. 4
0
 def xml(self):
     """ Generates the full document as an XML file
         Always written as a bytestream in UTF-8 encoding
     """
     self.__replaceGenerator()
     xml=PolyglotBytesIO()
     xml.write(_XMLPROLOGUE)
     self.topnode.toXml(0, xml)
     return xml.getvalue()
Esempio n. 5
0
 def xml(self):
     """ Generates the full document as an XML file
         Always written as a bytestream in UTF-8 encoding
     """
     self.__replaceGenerator()
     xml=PolyglotBytesIO()
     xml.write(_XMLPROLOGUE)
     self.topnode.toXml(0, xml)
     return xml.getvalue()
Esempio n. 6
0
 def toXml(self, filename=''):
     xml=PolyglotBytesIO()
     xml.write(_XMLPROLOGUE)
     self.body.toXml(0, xml)
     if not filename:
         return xml.getvalue()
     else:
         f=open(filename,'wb')
         f.write(xml.getvalue())
         f.close()
Esempio n. 7
0
 def toXml(self, filename=''):
     xml=PolyglotBytesIO()
     xml.write(_XMLPROLOGUE)
     self.body.toXml(0, xml)
     if not filename:
         return xml.getvalue()
     else:
         f=file(filename,'wb')
         f.write(xml.getvalue())
         f.close()
Esempio n. 8
0
 def contentxml(self):
     """ Generates the content.xml file
         Always written as a bytestream in UTF-8 encoding
     """
     xml=PolyglotBytesIO()
     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()