forked from DesenrollandoElCordel/code-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertion_xml.py
More file actions
56 lines (43 loc) · 1.99 KB
/
insertion_xml.py
File metadata and controls
56 lines (43 loc) · 1.99 KB
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
46
47
48
49
50
51
52
53
54
55
56
import os
import xml.etree.ElementTree as ET
folder = "/Users/elinaleblanc/Documents/Postdoctorat/Encodage/Moreno-TEI-files"
# print(folder)
for f in os.listdir(folder):
if f.endswith('.xml'):
xml_path = os.path.join(folder, f)
ns = {'tei': 'http://www.tei-c.org/ns/1.0'}
ET.register_namespace('', 'http://www.tei-c.org/ns/1.0')
tree = ET.parse(xml_path)
root = tree.getroot()
authority = root.find(".//tei:authority", ns)
# print(authority)
authority.set("role", "rightsHolder")
editorialDecl = root.find(".//tei:editorialDecl", ns)
# print(editorialDecl)
editorialDecl.set("corresp", "#automaticTranscription")
'''encodingDesc = root.find(".//tei:encodingDesc", ns)
print(encodingDesc)
project = ET.Element('projectDesc')
encodingDesc.insert(0, project)
ET.SubElement(project, "p")
for y in project.iter('p'):
description = 'Este archivo fue creado en el marco del proyecto Desenrollando el Cordel/Démêler le cordel/Untangling the cordel, dirigido por la profesora Constance Carta de la Universidad de Ginebra, con el apoyo de la Fundación filantrópica Famille Sandoz-Monique de Meuron.'
y.text = str(description)'''
'''cc = root.find(".//tei:availability", ns)
cc.remove(cc[0])'''
'''ET.SubElement(cc, "p")
for x in cc.iter('p'):
new_cc = 'CC-BY-NC-SA'
x.text = str(new_cc)'''
'''msId = root.find(".//tei:msIdentifier", ns)
collection = ET.Element('collection')
msId.insert(3, collection)
for c in msId.iter('collection'):
new_text = 'Colleción Moreno'
c.text = str(new_text)'''
'''new_folder = "encodage_updated/"
if not os.path.isdir(new_folder):
os.mkdir(new_folder)
new_path = os.path.join(new_folder, f)
# print(new_path)'''
tree.write(xml_path, encoding="UTF-8", xml_declaration=True)