Пример #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()
Пример #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()
Пример #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()
Пример #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()
Пример #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()
Пример #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()
Пример #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()
Пример #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()