27 from xml.sax
import make_parser,handler
28 from xml.sax.xmlreader
import InputSource
29 import xml.sax.saxutils
33 from cStringIO
import StringIO
35 from io
import StringIO
44 (OFFICENS,
'automatic-styles'), (OFFICENS,
'body'),
45 (OFFICENS,
'font-face-decls'), (OFFICENS,
'master-styles'),
46 (OFFICENS,
'meta'), (OFFICENS,
'scripts'),
47 (OFFICENS,
'settings'), (OFFICENS,
'styles') )
56 if self.
parse ==
False:
58 self.
data.append(data)
63 if self.
doc._parsing !=
"styles.xml" and tag == (OFFICENS,
'font-face-decls'):
65 if self.
parse ==
False:
70 content =
''.join(self.
data)
72 self.
parent.addText(content, check_grammar=
False)
76 for (att,value)
in attrs.items():
79 e =
Element(qname = tag, qattributes=attrdict, check_grammar=
False)
81 except AttributeError
as v:
82 print (
"Error: %s" % v)
84 if tag == (OFFICENS,
'automatic-styles'):
85 e = self.
doc.automaticstyles
86 elif tag == (OFFICENS,
'body'):
88 elif tag == (OFFICENS,
'master-styles'):
89 e = self.
doc.masterstyles
90 elif tag == (OFFICENS,
'meta'):
92 elif tag == (OFFICENS,
'scripts'):
94 elif tag == (OFFICENS,
'settings'):
96 elif tag == (OFFICENS,
'styles'):
98 elif self.
doc._parsing ==
"styles.xml" and tag == (OFFICENS,
'font-face-decls'):
99 e = self.
doc.fontfacedecls
100 elif hasattr(self,
'parent'):
101 self.
parent.addElement(e, check_grammar=
False)
106 if self.
parse ==
False:
109 str =
''.join(self.
data)
111 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.