use of biblemulticonverter.schema.roundtripxml.BibleType in project BibleMultiConverter by schierlm.
the class RoundtripXML method createBible.
protected JAXBElement<BibleType> createBible(Bible sBible) throws Exception {
ObjectFactory of = new ObjectFactory();
JAXBElement<BibleType> dBible = of.createBible(of.createBibleType());
dBible.getValue().setName(sBible.getName());
int dictCounter = 0;
for (Book sBook : sBible.getBooks()) {
BibleType.Book dBook = of.createBibleTypeBook();
dBook.setAbbr(sBook.getAbbr());
if (sBook.getId().equals(BookID.DICTIONARY_ENTRY)) {
dBook.setId(sBook.getId().getOsisID() + "-" + (++dictCounter));
} else {
dBook.setId(sBook.getId().getOsisID());
}
dBook.setShortName(sBook.getShortName());
dBook.setLongName(sBook.getLongName());
dBible.getValue().getBook().add(dBook);
for (Chapter sChapter : sBook.getChapters()) {
BibleType.Book.Chapter dChapter = of.createBibleTypeBookChapter();
dBook.getChapter().add(dChapter);
if (sChapter.getProlog() != null) {
dChapter.setProlog(of.createBibleTypeBookChapterProlog());
sChapter.getProlog().accept(new CreateContentVisitor(of, dChapter.getProlog().getContent()));
}
for (Verse sVerse : sChapter.getVerses()) {
BibleType.Book.Chapter.Verse dVerse = of.createBibleTypeBookChapterVerse();
dChapter.getVerse().add(dVerse);
dVerse.setNumber(sVerse.getNumber());
sVerse.accept(new CreateContentVisitor(of, dVerse.getContent()));
}
}
}
return dBible;
}
use of biblemulticonverter.schema.roundtripxml.BibleType in project BibleMultiConverter by schierlm.
the class RoundtripXML method parseBible.
protected Bible parseBible(JAXBElement<BibleType> sBible) throws Exception {
Bible dBible = new Bible(sBible.getValue().getName());
for (BibleType.Book sBook : sBible.getValue().getBook()) {
Book dBook = new Book(sBook.getAbbr(), BookID.fromOsisId(sBook.getId().replaceAll("-[0-9]+$", "")), sBook.getShortName(), sBook.getLongName());
dBible.getBooks().add(dBook);
for (BibleType.Book.Chapter sChapter : sBook.getChapter()) {
Chapter dChapter = new Chapter();
dBook.getChapters().add(dChapter);
if (sChapter.getProlog() != null) {
dChapter.setProlog(new FormattedText());
parseContent(dChapter.getProlog().getAppendVisitor(), sChapter.getProlog().getContent());
dChapter.getProlog().finished();
}
for (BibleType.Book.Chapter.Verse sVerse : sChapter.getVerse()) {
Verse dVerse = new Verse(sVerse.getNumber());
dChapter.getVerses().add(dVerse);
parseContent(dVerse.getAppendVisitor(), sVerse.getContent());
dVerse.finished();
}
}
}
return dBible;
}
use of biblemulticonverter.schema.roundtripxml.BibleType in project BibleMultiConverter by schierlm.
the class RoundtripXML method doExport.
@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
File file = new File(exportArgs[0]);
JAXBElement<BibleType> result = createBible(bible);
JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName());
Marshaller m = ctx.createMarshaller();
m.setSchema(getSchema());
m.marshal(result, file);
}
Aggregations