List, The attached patch is the current work that I have done which has taken mod2osis from completely broken to at least basically functional. I have not had the opportunity to test on a module which began life as non-OSIS. In fact, I've only tested on the latest KJV module. However, making the trip from module -> OSIS -> module with this patch in place gave me a module whose content which differs from the KJV in only the first verse of each segment of Psalm 119, starting beginning with verse 17 (Gimel). The difference seems to be in whitespace, though, not in displayed content - at least in Bibletime.
I didn't get a chance to check chapter headers/book headers (verse 0, chapter 0) with my script, but they do make an appearance in the OSIS file that is identical to their presence in the original KJV. Note, however, that the original KJV OSIS file and the one produced by the tool are not identical - there's some content in the header which is not maintained in Sword format, and the structure of a few items (some <div> tags at the end of several NT books) is moved around. Notably, the pre-verse title of each of the Psalms which has one has been moved to the inside of the chapter, as with a <div> note at the end of Romans and a few others, which the original has been moved from post-book to be inside of the verse. However, a round-trip is now at least close to possible. I have a few more tests to run of various option filters, but this is progress. --Greg
Index: utilities/mod2osis.cpp =================================================================== --- utilities/mod2osis.cpp (revision 2184) +++ utilities/mod2osis.cpp (working copy) @@ -12,6 +12,8 @@ #include <zipcomprs.h> #include <versekey.h> #include <thmlosis.h> +#include <osisplain.h> +#include <thmlplain.h> #include <stdio.h> #include <markupfiltmgr.h> #include <algorithm> @@ -35,6 +37,8 @@ { SWModule *inModule = 0; ThMLOSIS filter; + OSISPlain pfilter; + ThMLPlain pfilter2; if ((argc != 2)) { errorOutHelp(argv[0]); @@ -44,7 +48,8 @@ errorOutHelp(argv[0]); } - SWMgr mgr(new MarkupFilterMgr(FMT_OSIS)); + MarkupFilterMgr* mfm = new MarkupFilterMgr(FMT_OSIS); + SWMgr mgr(mfm); StringList options = mgr.getGlobalOptions(); for (StringList::iterator it = options.begin(); it != options.end(); it++) { StringList values = mgr.getGlobalOptionValues(it->c_str()); @@ -67,11 +72,13 @@ inModule = it->second; // inModule->AddRenderFilter(&filter); + inModule->AddStripFilter(&pfilter); + inModule->AddStripFilter(&pfilter2); SWKey *key = (SWKey *)*inModule; VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key); - char buf[1024]; + char buf[10240]; bool opentest = false; bool openbook = false; bool openchap = false; @@ -129,6 +136,7 @@ VerseKey tmpKey; tmpKey.Headings(1); tmpKey.AutoNormalize(0); + vkey->Headings(1); for ((*inModule) = TOP; !inModule->Error(); (*inModule)++) { bool newTest = false; @@ -143,9 +151,6 @@ cout << "\t</chapter>\n"; if (openbook) cout << "\t</div>\n"; - if (opentest) - cout << "\t</div>\n"; - cout << "\t<div type=\"x-testament\">\n"; opentest = true; newTest = true; } @@ -157,14 +162,21 @@ cout << "\t</div>\n"; } *buf = 0; - tmpKey = *vkey; - tmpKey.Chapter(0); - tmpKey.Verse(0); - sprintf(buf, "\t<div type=\"book\" osisID=\"%s\">\n", tmpKey.getOSISRef()); -// filter.ProcessText(buf, 200 - 3, &lastHeading, inModule); + const char * ref = vkey->getOSISRef(); + // Assume, for compatibility's sake, that all books are canonical - which is true for now + sprintf(buf, "\t<div type=\"book\" osisID=\"%s\" canonical=\"true\">\n", vkey->getOSISBookName()); + + char newref[256]; + sprintf(newref, "%s 0:0", vkey->getOSISBookName()); + *vkey = newref; + SWBuf title = inModule->getRawEntry(); + if(strlen(title.c_str()) > 0) sprintf(buf, "%s\t%s\n", buf, title.c_str()); cout << "" << buf << endl; openbook = true; newBook = true; + + // Need to restore + *vkey = ref; } if ((vkey->Chapter() != lastChap) || newBook) { if (!newBook) { @@ -172,12 +184,21 @@ cout << "\t</chapter>\n"; } *buf = 0; - tmpKey = *vkey; - tmpKey.Verse(0); - sprintf(buf, "\t<chapter osisID=\"%s\">\n", tmpKey.getOSISRef()); -// filter.ProcessText(buf, 200 - 3, &lastHeading, inModule); + const char * ref = vkey->getOSISRef(); + + char newref[256]; + sprintf(newref, "%s %i:0", vkey->getOSISBookName(), vkey->Chapter()); + *vkey = newref; + SWBuf title = inModule->getRawEntry(); + SWBuf plainTitle = title; + inModule->stripFilter(plainTitle, vkey); + if(strlen(title.c_str()) > 0) sprintf(buf, "\t<chapter osisID=\"%s.%i\" chapterTitle=\"%s\">\n\t%s\n", vkey->getOSISBookName(), vkey->Chapter(), plainTitle.c_str(), title.c_str()); + else sprintf(buf, "\t<chapter osisID=\"%s.%i\">\n", vkey->getOSISBookName(), vkey->Chapter()); cout << "" << buf; openchap = true; + + // Need to restore + *vkey = ref; } SWBuf verseText = inModule->getRawEntry(); sprintf(buf, "\t\t<verse osisID=\"%s\">", vkey->getOSISRef()); @@ -187,11 +208,9 @@ lastTest = vkey->Testament(); } if (openchap) - cout << "\t</chapter>\n"; + cout << "\t\t\t</chapter>\n"; if (openbook) - cout << "\t</div>\n"; - if (opentest) - cout << "\t</div>\n"; + cout << "\t\t</div>\n"; cout << "\t</osisText>\n"; cout << "</osis>\n"; return 0;
_______________________________________________ sword-devel mailing list: sword-devel@crosswire.org http://www.crosswire.org/mailman/listinfo/sword-devel Instructions to unsubscribe/change your settings at above page