Skip to content

Commit

Permalink
Add manuscript edition to the bibliographic meta data
Browse files Browse the repository at this point in the history
Taken from `mods:edition`, put into `tei:biblFull/editionStmt`.
  • Loading branch information
wrznr committed Jul 23, 2019
1 parent 2866d2f commit 3ac974c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
15 changes: 15 additions & 0 deletions mets_mods2teiHeader/api/mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self):
self.places = None
self.dates = None
self.publishers = None
self.edition = None
self.digital_origin = None
self.owner_digital = None
self.license = None
Expand Down Expand Up @@ -156,6 +157,14 @@ def __spur(self):
for publisher in self.tree.xpath("//mets:dmdSec[1]//mods:mods/mods:originInfo[1]/mods:publisher", namespaces=ns):
self.publishers.append(publisher.text)

#
# edition of the manuscript
edition = self.tree.xpath("//mets:dmdSec[1]//mods:mods/mods:originInfo[1]/mods:edition", namespaces=ns)
if edition:
self.edition = edition[0].text
else:
self.edition = ""

#
# digital_origin
for digital_origin in self.tree.xpath("//mets:dmdSec[1]//mods:mods/mods:physicalDescription[1]/mods:digitalOrigin", namespaces=ns):
Expand Down Expand Up @@ -280,6 +289,12 @@ def get_publishers(self):
"""
return self.publishers

def get_edition(self):
"""
Return the edition of the source manuscript
"""
return self.edition

def has_digital_origin(self):
"""
Element "digitalOrigin" present?
Expand Down
9 changes: 9 additions & 0 deletions mets_mods2teiHeader/api/tei.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ def add_publisher(self, publisher):
name.text = publisher
publication_stmt.insert(0, publisher_node)

def add_source_edition(self, manuscript_edition):
"""
Adds an edition statement with details on the source manuscript.
"""
bibl_full = self.tree.xpath('//tei:fileDesc/tei:sourceDesc/tei:biblFull', namespaces=ns)[0]
edition_stmt = etree.SubElement(bibl_full, "editionStmt")
edition = etree.SubElement(edition_stmt, "edition")
edition.text = manuscript_edition

def add_digital_edition(self, digital_edition):
"""
Adds an edition statement with details on the digital edition.
Expand Down
3 changes: 0 additions & 3 deletions mets_mods2teiHeader/data/tei_skeleton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
<titleStmt>
<title level="m" type="main">[Haupttitel einer Monographie]</title>
</titleStmt>
<editionStmt>
<edition n="1"/>
</editionStmt>
<publicationStmt>
</publicationStmt>
</biblFull>
Expand Down
4 changes: 4 additions & 0 deletions mets_mods2teiHeader/scripts/mets_mods2teiHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def cli(mets):
for publisher in mets.get_publishers():
tei.add_publisher(publisher)

# manuscript edition
if mets.get_edition():
tei.add_source_edition(mets.get_edition())

# digital edition
if mets.has_digital_origin():
tei.add_digital_edition(mets.get_digital_origin())
Expand Down

0 comments on commit 3ac974c

Please sign in to comment.