Skip to content

Commit

Permalink
Add xml id's when merging if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsINT committed Oct 15, 2024
1 parent 0736f1b commit 02760a7
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ open class TEITextMerger(
}
// Both <w> and <pc> have a pos.
wTag.setAttribute(posType(), termToAdd.posOrEmpty)
wTag.setAttribute("xml:id", termToAdd.targets.first().id)
return wTag
}

Expand Down Expand Up @@ -307,6 +308,10 @@ open class TEITextMerger(
}
element.setAttribute(posType(), termToAdd.posOrEmpty)
element.removeAttribute("type") // Update legacy formats to TEI p5
// First check if the element has an id already, else add it.
if (element.getAttribute("xml:id").isNullOrBlank()) {
element.setAttribute("xml:id", termToAdd.targets.first().id)
}
}

private fun getWordFormsToAdd(): List<WordForm> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal class TEIExportTest {
.ignoreTrailingWhiteSpaces()
.ignoreDate()
.ignoreUUID()
.ignoreWhiteSpaceDocumentWide()
.result()
}

Expand All @@ -52,6 +53,7 @@ internal class TEIExportTest {
.mergeTEI(Resource.get("tei/brieven/input.tei.xml"), layer)
.ignoreDate()
.ignoreUUID()
.ignoreWhiteSpaceDocumentWide()
.result()
}

Expand Down
Loading

0 comments on commit 02760a7

Please sign in to comment.