1 # -*- coding: utf-8 -*-
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
7 from . import DCNS, SSTNS
8 from . import core, meta
11 class SSTParser(etree.XMLParser):
12 """ XML parser using relevant element classes. """
14 super(SSTParser, self).__init__()
15 lookup = etree.ElementNamespaceClassLookup()
16 self.set_element_class_lookup(lookup)
18 # Define core language tags.
19 sst_ns = lookup.get_namespace(SSTNS.uri)
20 sst_ns['aside'] = core.Aside
21 sst_ns['div'] = core.Div
22 sst_ns['header'] = core.Header
23 sst_ns['section'] = core.Section
24 sst_ns['span'] = core.Span
25 sst_ns['metadata'] = meta.Metadata
27 # Define any special metadata.
28 dc_ns = lookup.get_namespace(DCNS.uri)
29 dc_ns['creator'] = meta.Person
30 dc_ns['identifier'] = meta.Identifier