24 #pragma warning( disable: 4251 )
45 #ifndef NO_SWORD_NAMESPACE
46 using namespace sword;
53 cerr << appName <<
" - a tool to output a SWORD module in OSIS format\n";
54 cerr <<
"usage: "<< appName <<
" <modname> \n";
60 int main(
int argc,
char **argv)
62 SWModule *inModule = 0;
65 cerr <<
"\n\n*** Don't use this utility *** \n\n";
66 cerr <<
"Its purpose is to prove the engine can do\n";
67 cerr <<
"lossless import / export, but we are not there yet. \n\n";
68 cerr <<
"This utility is done, in fact it is already too complex.\n";
69 cerr <<
"The ENGINE needs more work to assure export as OSIS works\n";
70 cerr <<
"This utility only gives us occasion to improve the engine.\n";
71 cerr <<
"Our goal is not to produce an export tool.\n\n";
72 cerr <<
"In fact, you should never export SWORD modules.\n";
73 cerr <<
"Many CrossWire modules are licensed for use from publishers\n";
74 cerr <<
"and you will need to obtain your own permissions.\n";
75 cerr <<
"We also do not encourage propagating encoding errors\n";
76 cerr <<
"which you will avoid by obtaining text data from the source.\n\n";
77 cerr <<
"Please see the TextSource entry in the module's .conf file\n";
78 cerr <<
"for information where to obtain module data from our source.\n\n";
79 cerr <<
"If you still must export SWORD module data, use mod2imp.\n";
80 cerr <<
"It is more lossless; or less lossful, and easier to read.\n\n";
86 if ((!strcmp(argv[1],
"-h")) || (!strcmp(argv[1],
"--help")) || (!strcmp(argv[1],
"/?")) || (!strcmp(argv[1],
"-?")) || (!strcmp(argv[1],
"-help"))) {
92 for (StringList::iterator it = options.begin(); it != options.end(); it++) {
93 StringList values = mgr.getGlobalOptionValues(it->c_str());
94 if (find(values.begin(), values.end(),
"On") != values.end()) {
95 mgr.setGlobalOption(it->c_str(),
"On");
97 if (find(values.begin(), values.end(),
"All Readings") != values.end()) {
98 mgr.setGlobalOption(it->c_str(),
"All Readings");
105 ModMap::iterator it = mgr.Modules.find(argv[1]);
106 if (it == mgr.Modules.end()) {
107 fprintf(stderr,
"error: %s: couldn't find module: %s \n", argv[0], argv[1]);
111 inModule = it->second;
114 SWKey *key = (SWKey *)*inModule;
118 bool opentest =
false;
119 bool openbook =
false;
120 bool openchap =
false;
125 cerr <<
"Currently mod2osis only works with verse keyed modules\n\n";
129 vkey->setIntros(
false);
131 cout <<
"<?xml version=\"1.0\" ";
132 if (inModule->getConfigEntry(
"Encoding")) {
133 if (*(inModule->getConfigEntry(
"Encoding")))
134 cout <<
"encoding=\"" << inModule->getConfigEntry(
"Encoding") <<
"\" ";
135 else cout <<
"encoding=\"UTF-8\" ";
137 else cout <<
"encoding=\"UTF-8\" ";
142 cout <<
" xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\"";
143 cout <<
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
144 cout <<
" xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.2.1.1.xsd\">\n\n";
146 cout <<
" osisIDWork=\"";
147 cout << inModule->getName() <<
"\"";
148 cout <<
" osisRefWork=\"defaultReferenceScheme\"";
149 if (inModule->getLanguage()) {
150 if (strlen(inModule->getLanguage()))
151 cout <<
" xml:lang=\"" << inModule->getLanguage() <<
"\"";
155 cout <<
"\t<header>\n";
156 cout <<
"\t\t<work osisWork=\"";
157 cout << inModule->getName() <<
"\">\n";
158 cout <<
"\t\t\t<title>" << inModule->getDescription() <<
"</title>\n";
159 cout <<
"\t\t\t<identifier type=\"OSIS\">Bible." << inModule->getName() <<
"</identifier>\n";
160 cout <<
"\t\t\t<refSystem>Bible.KJV</refSystem>\n";
161 cout <<
"\t\t</work>\n";
162 cout <<
"\t\t<work osisWork=\"defaultReferenceScheme\">\n";
163 cout <<
"\t\t\t<refSystem>Bible.KJV</refSystem>\n";
164 cout <<
"\t\t</work>\n";
165 cout <<
"\t</header>\n\n";
170 SWKey *p = inModule->createKey();
174 tmpKey =
new VerseKey();
176 *tmpKey = inModule->getKeyText();
178 tmpKey->setIntros(
true);
179 tmpKey->setAutoNormalize(
false);
181 for ((*inModule) =
TOP; !inModule->popError(); (*inModule)++) {
182 bool newTest =
false;
183 bool newBook =
false;
185 if (!strlen(inModule->renderText())) {
189 if ((vkey->getTestament() != lastTest)) {
191 cout <<
"\t</chapter>\n";
193 cout <<
"\t</div>\n";
195 cout <<
"\t</div>\n";
196 cout <<
"\t<div type=\"x-testament\">\n";
200 if ((vkey->getBook() != lastBook) || newTest) {
203 cout <<
"\t</chapter>\n";
205 cout <<
"\t</div>\n";
209 tmpKey->setChapter(0);
211 sprintf(buf,
"\t<div type=\"book\" osisID=\"%s\">\n", tmpKey->getOSISRef());
213 cout <<
"" << buf << endl;
217 if ((vkey->getChapter() != lastChap) || newBook) {
220 cout <<
"\t</chapter>\n";
225 sprintf(buf,
"\t<chapter osisID=\"%s\">\n", tmpKey->getOSISRef());
230 SWBuf verseText = inModule->getRawEntry();
231 sprintf(buf,
"\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
232 cout << buf << verseText.c_str() <<
"</verse>\n" << endl;
233 lastChap = vkey->getChapter();
234 lastBook = vkey->getBook();
235 lastTest = vkey->getTestament();
238 cout <<
"\t</chapter>\n";
240 cout <<
"\t</div>\n";
242 cout <<
"\t</div>\n";
243 cout <<
"\t</osisText>\n";
std::list< SWBuf > StringList
#define SWDYNAMIC_CAST(className, object)
void errorOutHelp(char *appName)