Skip to content

Commit

Permalink
prevent duplicate IDs in the root element
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Mar 3, 2021
1 parent 66778eb commit 6736104
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion foliatools/foliasplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def split(doc, expression, batchsize=1, copymetadata=False, require_submetadata=
for key, value in submetadata.items():
childdoc.metadata[key] = value
#add main body element (text or speech)
body = childdoc.append(doc.data[0].__class__(childdoc, id=doc.id + id_suffix + "." + doc.data[0].XMLTAG))
bodyid = doc.id + id_suffix + "." + doc.data[0].XMLTAG
if bodyid in doc:
bodyid = bodyid + ".split"
body = childdoc.append(doc.data[0].__class__(childdoc, id=bodyid))
if external:
if substituted:
match.parent.data.remove(match)
Expand Down Expand Up @@ -122,6 +125,7 @@ def main():
for i, childdoc in enumerate(split(doc, args.query, args.batchsize, args.copymetadata, args.submetadata, args.suffixtemplate, args.alterids, args.external, None, args.deep)):
print("#" + str(i+1) + " - " + childdoc.id + ".folia.xml", file=sys.stderr)
childdoc.save(os.path.join(args.outputdir, childdoc.id) + ".folia.xml")
del childdoc

if args.external:
print("Saving parent document - " + os.path.basename(filename), file=sys.stderr)
Expand Down

0 comments on commit 6736104

Please sign in to comment.