Skip to content

Commit a4dd466

Browse files
committed
USX3 export: strip empty word level attributes
While technically, in USFM, `|strong=""` is not valid either, it exists in real world bibles. Exporting tu USX3 results in a Schema validation error, therefore strip them. Fixes #100
1 parent 8833853 commit a4dd466

File tree

1 file changed

+10
-6
lines changed
  • biblemulticonverter/src/main/java/biblemulticonverter/format/paratext

1 file changed

+10
-6
lines changed

biblemulticonverter/src/main/java/biblemulticonverter/format/paratext/USX3.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -751,18 +751,22 @@ public ParatextCharacterContent.ParatextCharacterContentVisitor<IOException> vis
751751
@Override
752752
public ParatextCharacterContent.ParatextCharacterContentVisitor<IOException> visitAutoClosingFormatting(ParatextCharacterContent.AutoClosingFormattingKind kind, Map<String, String> attributes) throws IOException {
753753
Char chr = new Char();
754-
chr.setLemma(attributes.get("lemma"));
755-
chr.setStrong(attributes.get("strong"));
756-
chr.setSrcloc(attributes.get("srcloc"));
757-
chr.setLinkHref(attributes.get("link-href"));
758-
chr.setLinkId(attributes.get("link-id"));
754+
chr.setLemma(nullIfEmpty(attributes.get("lemma")));
755+
chr.setStrong(nullIfEmpty(attributes.get("strong")));
756+
chr.setSrcloc(nullIfEmpty(attributes.get("srcloc")));
757+
chr.setLinkHref(nullIfEmpty(attributes.get("link-href")));
758+
chr.setLinkId(nullIfEmpty(attributes.get("link-id")));
759759
chr.setLinkTitle(attributes.get("link-title"));
760-
chr.setGloss(attributes.get("gloss"));
760+
chr.setGloss(nullIfEmpty(attributes.get("gloss")));
761761
chr.setStyle(CHAR_KIND_MAP.get(kind));
762762
target.add(chr);
763763
return new USX3.USXCharacterContentVisitor(chr.getContent());
764764
}
765765

766+
private String nullIfEmpty(String s) {
767+
return s == null || s.isEmpty() ? null : s;
768+
}
769+
766770
@Override
767771
public void visitMilestone(String tag, Map<String, String> attributes) throws IOException {
768772
Ms ms = new Ms();

0 commit comments

Comments
 (0)