Skip to content

Commit

Permalink
Improve robustness of OSIS import
Browse files Browse the repository at this point in the history
Do not fail if metadata fields contain line breaks or non-normalized
whitespace.
  • Loading branch information
schierlm committed Nov 18, 2016
1 parent c55ee61 commit 48d4dc9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public Bible doImport(File inputFile) throws Exception {
String titleDesc = xpath.evaluate("/osis/osisText/titlePage/description/text()", osisDoc);
MetadataBook mb = new MetadataBook();
if (!description.isEmpty())
mb.setValue(MetadataBookKey.description, description.trim());
mb.setValue(MetadataBookKey.description, description.replaceAll("[\r\n\t ]+", " ").trim());
if (!rights.isEmpty())
mb.setValue(MetadataBookKey.rights, rights.trim());
mb.setValue(MetadataBookKey.rights, rights.replaceAll("[\r\n\t ]+", " ").trim());
if (!date.isEmpty())
mb.setValue(MetadataBookKey.date, date);
if (!titleDesc.isEmpty())
mb.setValue("description@titlePage", titleDesc.trim());
mb.setValue("description@titlePage", titleDesc.replaceAll("[\r\n\t ]+", " ").trim());
mb.finished();
result.getBooks().add(mb.getBook());
}
Expand Down

0 comments on commit 48d4dc9

Please sign in to comment.