Skip to content

Commit

Permalink
OSIS: Fix regression in <w> attribute parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
schierlm committed Oct 17, 2024
1 parent 89381a0 commit 6f319a6
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -842,30 +842,32 @@ private void parseStructuredTextElement(Visitor<RuntimeException> vv, Element el
idx[i] = Integer.parseInt(strs[i]);
}
}
if (strong == null && rmac.isEmpty() && idx == null) {
printWarning("INFO: Skipped <w> tag without any usable information");
} else {
boolean grammarXattr = Boolean.getBoolean("biblemulticonverter.osis.grammar.xattr");
String[] attributeKeys = null, attributeValues = null;
if (!grammarXattr) {
List<String[]> attrPairs = new ArrayList<>();
for(String[] grammarTag : grammarTags) {
String[] parts = grammarTag[1].split(":", 2);
if (parts.length == 2 && parts[0].matches("[a-z0-9-]+")) {
String key = "osisgrammar:"+grammarTag[0]+":"+parts[0];
if (key.equals("osisgrammar:lemma:lemma")) {
key = "lemma";
}
attrPairs.add(new String[] {key, parts[1]});
boolean grammarXattr = Boolean.getBoolean("biblemulticonverter.osis.grammar.xattr");
String[] attributeKeys = null, attributeValues = null;
if (!grammarXattr) {
List<String[]> attrPairs = new ArrayList<>();
for(String[] grammarTag : grammarTags) {
String[] parts = grammarTag[1].split(":", 2);
if (parts.length == 2 && parts[0].matches("[a-z0-9-]+")) {
String key = "osisgrammar:"+grammarTag[0]+":"+parts[0];
if (key.equals("osisgrammar:lemma:lemma")) {
key = "lemma";
}
attrPairs.add(new String[] {key, parts[1]});
}
}
if (!attrPairs.isEmpty()) {
attributeKeys = new String[attrPairs.size()];
attributeValues = new String[attrPairs.size()];
for (int i = 0; i < attributeKeys.length; i++) {
attributeKeys[i] = attrPairs.get(i)[0];
attributeValues[i] = attrPairs.get(i)[0];
}
}
}
if (strong == null && rmac.isEmpty() && idx == null && attributeKeys == null) {
printWarning("INFO: Skipped <w> tag without any usable information");
} else {
v = v.visitGrammarInformation(strongPfx, strong, strongSfx, rmac.isEmpty() ? null : rmac.toArray(new String[rmac.size()]), idx, attributeKeys, attributeValues);
if (grammarXattr) {
for(String[] grammarTag : grammarTags) {
Expand Down

0 comments on commit 6f319a6

Please sign in to comment.