diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-09-13 16:04:20 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-09-13 16:04:20 +0100 |
| commit | 49b252868d153df6b259ab5198213a11a1eb1c39 (patch) | |
| tree | a3afcf99db0127a5af0dc894c8f130dc616ada21 | |
| parent | 3fca7d9cbc812671bc7d4b2bac85638775a3da14 (diff) | |
Use cobble to generate XML data types
| -rw-r--r-- | mammoth/docx/xmlparser.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mammoth/docx/xmlparser.py b/mammoth/docx/xmlparser.py index 43d5eb4..4e963db 100644 --- a/mammoth/docx/xmlparser.py +++ b/mammoth/docx/xmlparser.py @@ -1,9 +1,14 @@ -import collections import xml.sax +import cobble -XmlElementBase = collections.namedtuple("XmlElement", ["name", "attributes", "children"]) -class XmlElement(XmlElementBase): + +@cobble.data +class XmlElement(object): + name = cobble.field() + attributes = cobble.field() + children = cobble.field() + def find_child_or_null(self, name): return self.find_child(name) or _null_xml_element @@ -48,7 +53,9 @@ class NullXmlElement(object): _null_xml_element = NullXmlElement() -XmlText = collections.namedtuple("XmlText", ["value"]) +@cobble.data +class XmlText(object): + value = cobble.field() def element(name, attributes=None, children=None): |
