27 from defusedxml.sax
import make_parser
28 from xml.sax
import handler
29 from xml.sax.xmlreader
import InputSource
30 import xml.sax.saxutils
34 from cStringIO
import StringIO
36 from io
import StringIO
45 (OFFICENS,
'automatic-styles'), (OFFICENS,
'body'),
46 (OFFICENS,
'font-face-decls'), (OFFICENS,
'master-styles'),
47 (OFFICENS,
'meta'), (OFFICENS,
'scripts'),
48 (OFFICENS,
'settings'), (OFFICENS,
'styles') )
57 if self.
parse ==
False:
59 self.
data.append(data)
64 if self.
doc._parsing !=
"styles.xml" and tag == (OFFICENS,
'font-face-decls'):
66 if self.
parse ==
False:
71 content =
''.join(self.
data)
73 self.
parent.addText(content, check_grammar=
False)
77 for (att,value)
in attrs.items():
80 e =
Element(qname = tag, qattributes=attrdict, check_grammar=
False)
82 except AttributeError
as v:
83 print (
"Error: %s" % v)
85 if tag == (OFFICENS,
'automatic-styles'):
86 e = self.
doc.automaticstyles
87 elif tag == (OFFICENS,
'body'):
89 elif tag == (OFFICENS,
'master-styles'):
90 e = self.
doc.masterstyles
91 elif tag == (OFFICENS,
'meta'):
93 elif tag == (OFFICENS,
'scripts'):
95 elif tag == (OFFICENS,
'settings'):
97 elif tag == (OFFICENS,
'styles'):
99 elif self.
doc._parsing ==
"styles.xml" and tag == (OFFICENS,
'font-face-decls'):
100 e = self.
doc.fontfacedecls
101 elif hasattr(self,
'parent'):
102 self.
parent.addElement(e, check_grammar=
False)
107 if self.
parse ==
False:
110 str =
''.join(self.
data)
112 self.
curr.addText(str, check_grammar=
False)
def characters(self, data)
def startElementNS(self, tag, qname, attrs)
def __init__(self, document)
def endElementNS(self, tag, qname)
Creates a arbitrary element and is intended to be subclassed not used on its own. ...
Extract headings from content.xml of an ODT file.