diff --git a/samples/EnumVal/EnumVal.cpp b/samples/EnumVal/EnumVal.cpp index 196022a1801a762d8618a87dd0381fd4fcd78fda..55e0610818b92afb4149c922215fb3802d8be075 100644 --- a/samples/EnumVal/EnumVal.cpp +++ b/samples/EnumVal/EnumVal.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2000/05/31 18:50:42 rahulj + * Removed extraneous command line arguments. + * * Revision 1.7 2000/03/03 01:29:30 roddey * Added a scanReset()/parseReset() method to the scanner and * parsers, to allow for reset after early exit from a progressive parse. @@ -149,10 +152,25 @@ inline ostream& operator<<(ostream& target, const StrX& toDump) } +// --------------------------------------------------------------------------- +// Local helper methods +// --------------------------------------------------------------------------- +static void usage() +{ + cout << "\nUsage:\n" + " EnumVal <XML file>\n\n" + "This program parses a file, then shows how to enumerate the\n" + "contents of the validator pools. Essentially, shows how one can\n" + "access the DTD information stored in internal data structures.\n\n" + " * = Default if not provided explicitly\n" + << endl; +} + + // --------------------------------------------------------------------------- // Program entry point // --------------------------------------------------------------------------- -int main(int argc, char* args[]) +int main(int argC, char* argV[]) { // Initialize the XML4C system try @@ -164,39 +182,28 @@ int main(int argc, char* args[]) { cerr << "Error during initialization! Message:\n" << StrX(toCatch.getMessage()) << endl; + XMLPlatformUtils::Terminate(); return 1; } - // We only have one required parameter, which is the file to process - if (argc < 2) - { - usage(); - return -1; - } - const char* xmlFile = args[1]; - bool doValidation = false; - - // Check for some special cases values of the parameter - if (!strncmp(xmlFile, "-?", 2)) + // Check command line and extract arguments. + if (argC < 2) { usage(); - return 0; + XMLPlatformUtils::Terminate(); + return 1; } - else if (!strncmp(xmlFile, "-v", 2)) - { - doValidation = true; - if (argc < 3) - { - usage(); - return -1; - } - xmlFile = args[2]; - } - else if (xmlFile[0] == '-') + + // We only have one required parameter, which is the file to process + if ((argC == 2) && !strcmp(argV[1], "-?")) { usage(); - return -1; + XMLPlatformUtils::Terminate(); + return 2; } + + const char* xmlFile = argV[1]; + SAXParser::ValSchemes valScheme = SAXParser::Val_Auto; // // Create a DTD validator to be used for our validation work. Then create @@ -206,7 +213,7 @@ int main(int argc, char* args[]) // DTDValidator* valToUse = new DTDValidator; SAXParser parser(valToUse); - parser.setDoValidation(doValidation); + parser.setValidationScheme(valScheme); // // Get the starting time and kick off the parse of the indicated @@ -222,7 +229,8 @@ int main(int argc, char* args[]) cerr << "\nError during parsing: '" << xmlFile << "'\n" << "Exception message is: \n" << StrX(e.getMessage()) << "\n" << endl; - return -1; + XMLPlatformUtils::Terminate(); + return 3; } // @@ -308,16 +316,3 @@ int main(int argc, char* args[]) } -// --------------------------------------------------------------------------- -// Local helper methods -// --------------------------------------------------------------------------- -static void usage() -{ - cout << "\nUsage:\n" - " EnumVal [-v] <XML file>\n" - " -v Do a validating parse. Defaults to non-validating.\n" - "This program parses a file, then shows how to enumerate the" - "contents of the validator pools\n" << endl; -} - - diff --git a/samples/Redirect/Redirect.cpp b/samples/Redirect/Redirect.cpp index f3a9016905de5afa9e270a792f665395e5ef7ab8..3cf88b27611f3103354679f967e2d7f46d8d19d0 100644 --- a/samples/Redirect/Redirect.cpp +++ b/samples/Redirect/Redirect.cpp @@ -75,6 +75,9 @@ * to read the contents of 'personal.dtd'. * * $Log$ + * Revision 1.4 2000/05/31 18:53:15 rahulj + * Removed extraneous command line arguments. + * * Revision 1.3 2000/02/11 02:38:28 abagchi * Removed StrX::transcode * @@ -103,13 +106,13 @@ void usage() { cout << "\nUsage:\n" - << " Redirect [-v] <XML file>\n" - << " -v Invoke the Validating SAX Parser.\n\n" - << "This program installs an entity resolver, traps the call to\n" - << "the external DTD file and redirects it to another application\n" - << "specific file which contains the actual dtd.\n\n" - << "The program then counts and reports the number of elements and\n" - << "attributes in the given XML file.\n" << endl; + " Redirect <XML file>\n\n" + "This program installs an entity resolver, traps the call to\n" + "the external DTD file and redirects it to another application\n" + "specific file which contains the actual dtd.\n\n" + "The program then counts and reports the number of elements and\n" + "attributes in the given XML file.\n" + << endl; } @@ -127,6 +130,7 @@ int main(int argc, char* args[]) { cerr << "Error during initialization! Message:\n" << StrX(toCatch.getMessage()) << endl; + XMLPlatformUtils::Terminate(); return 1; } @@ -134,40 +138,24 @@ int main(int argc, char* args[]) if (argc < 2) { usage(); - return -1; + XMLPlatformUtils::Terminate(); + return 1; } - const char* xmlFile = args[1]; - bool doValidation = false; + const char* xmlFile = args[1]; // Check for some special cases values of the parameter - if (!strncmp(xmlFile, "-?", 2)) + if (xmlFile[0] == '-') { usage(); + XMLPlatformUtils::Terminate(); return 0; } - else if (!strncmp(xmlFile, "-v", 2)) - { - doValidation = true; - if (argc < 3) - { - usage(); - return -1; - } - xmlFile = args[2]; - } - else if (xmlFile[0] == '-') - { - usage(); - return -1; - } - // // Create a SAX parser object. Then, according to what we were told on // the command line, set it to validate or not. // SAXParser parser; - parser.setDoValidation(doValidation); // // Create our SAX handler object and install it on the parser, as the