String input = null;
OutputStream output = System.out;
EntityResolver entityResolver = null;
if ( args.length < 1 || 5 < args.length){
System.err.println("Flatten [-out output-file] [-dtd dtd] input ");
}
for (int i = 0; i < args.length; i++){
if (args[i].equals("-out")){
output = new FileOutputStream(new File(args[++i]));
break;
}
if (args[i].equals("-dtd")){
entityResolver = new MyEntityResolver(args[++i]);
break;
}
input = args[i];
}
VariableResolver vr = new VariableResolver();
if (null != entityResolver){
vr.setEntityResolver(entityResolver);
}
// vr.setParent(getXmlReader());
vr.setContentHandler(getContentHandler(output));
vr.parse(new InputSource(input));