forked from SavinaRoja/OpenAccess_EPUB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossrefs.py
45 lines (38 loc) · 1.52 KB
/
crossrefs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import utils
"""Crossreferences"""
class Xref(object):
"""The top level class of crossreferences."""
def __init__(self, xrefnode):
self.rid = xrefnode.getAttribute('id')
def __str__(self):
return 'Reference ID: {0}'.format(self.rid)
class Affiliation(Xref):
"""An affiliation crossreference."""
def __init__(self, xrefnode):
Xref.__init__(self, xrefnode)
self.address = None
addrline = xrefnode.getElementsByTagName('addr-line')
if addrline:
self.address = addrline[0].firstChild.data
else:
for child in xrefnode.childNodes:
if child.nodeType == child.TEXT_NODE and not child.data == u'\n':
self.address = child.data
def __str__(self):
return 'Reference ID: {0}, Address Line: {1}'.format(self.rid,
self.address)
class Correspondence(Xref):
"""A Correspondence crossreference."""
def __init__(self, xrefnode):
Xref.__init__(self, xrefnode)
self.address = None
addrline = xrefnode.getElementsByTagName('addr-line')
if addrline:
self.address = addrline[0].firstChild.data
self.email = None
email = xrefnode.getElementsByTagName('email')
if email:
self.email = email[0].firstChild.data
def __str__(self):
out = 'Reference ID: {0}, Address Line: {1}, Email: {2}'
return out.format(self.rid, self.address, self.email)