@Override public void processContent(Book book, Key key, Element ele) { String refstr = ele.getValue(); try { if (ele.getAttribute(OSISUtil.OSIS_ATTR_REF) == null) { Passage ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key); String osisname = ref.getOsisRef(); ele.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname); } } catch (NoSuchKeyException ex) { DataPolice.report(book, key, "scripRef has no passage attribute, unable to guess: (" + refstr + ") due to " + ex.getMessage()); } } }
@Override public Element processTag(Book book, Key key, Element ele, Attributes attrs) { Element reference = null; String refstr = attrs.getValue("passage"); if (refstr != null) { Passage ref = null; try { ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key); } catch (NoSuchKeyException ex) { DataPolice.report(book, key, "Unparsable passage: (" + refstr + ") due to " + ex.getMessage()); } // If we don't have a Passage then use the original string String osisname = ref != null ? ref.getOsisRef() : refstr; reference = OSISUtil.factory().createReference(); reference.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname); } else { // The reference will be filled in by processContent reference = OSISUtil.factory().createReference(); } if (ele != null) { ele.addContent(reference); } return reference; }