} */
// variables
Test test = new Test();
ParserWrapper parser = null;
boolean namespaces = DEFAULT_NAMESPACES;
boolean validation = DEFAULT_VALIDATION;
boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
boolean deferredDom = DEFAULT_DEFERRED_DOM;
String inputfile="tests/dom/rename/input.xml";
// process arguments
for (int i = 0; i < argv.length; i++) {
String arg = argv[i];
if (arg.startsWith("-")) {
String option = arg.substring(1);
if (option.equals("p")) {
// get parser name
if (++i == argv.length) {
System.err.println("error: Missing argument to -p"
+ " option.");
}
String parserName = argv[i];
// create parser
try {
parser = (ParserWrapper)
Class.forName(parserName).newInstance();
}
catch (Exception e) {
parser = null;
System.err.println("error: Unable to instantiate "
+ "parser (" + parserName + ")");
}
continue;
}
if (option.equalsIgnoreCase("n")) {
namespaces = option.equals("n");
continue;
}
if (option.equalsIgnoreCase("v")) {
validation = option.equals("v");
continue;
}
if (option.equalsIgnoreCase("s")) {
schemaValidation = option.equals("s");
continue;
}
if (option.equalsIgnoreCase("f")) {
schemaFullChecking = option.equals("f");
continue;
}
if (option.equalsIgnoreCase("d")) {
deferredDom = option.equals("d");
continue;
}
if (option.equals("h")) {
printUsage();
continue;
}
}
}
// use default parser?
if (parser == null) {
// create parser
try {
parser = (ParserWrapper)
Class.forName(DEFAULT_PARSER_NAME).newInstance();
}
catch (Exception e) {
System.err.println("error: Unable to instantiate parser ("
+ DEFAULT_PARSER_NAME + ")");
System.exit(1);
}
}
// set parser features
try {
parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
}
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("
+ NAMESPACES_FEATURE_ID + ")");
}
try {
parser.setFeature(VALIDATION_FEATURE_ID, validation);
}
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("
+ VALIDATION_FEATURE_ID + ")");
}
try {
parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
schemaValidation);
}
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("
+ SCHEMA_VALIDATION_FEATURE_ID + ")");
}
try {
parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
schemaFullChecking);
}
catch (SAXException e) {
System.err.println("warning: Parser does not support feature ("
+ SCHEMA_FULL_CHECKING_FEATURE_ID + ")");
}
if (parser instanceof dom.wrappers.Xerces) {
try {
parser.setFeature(DEFERRED_DOM_FEATURE_ID,
deferredDom);
}
catch (SAXException e) {
System.err.println("warning: Parser does not support " +
"feature (" +
DEFERRED_DOM_FEATURE_ID + ")");
}
}
Document document = null;
// parse file
try {
document = parser.parse(inputfile);
}
catch (SAXParseException e) {
// ignore
}
catch (Exception e) {