else
xsl = new StyleScript();
xsl.setStylePath(stylePath);
Templates stylesheet;
stylesheet = xsl.newTemplates(xslName);
for (; i < args.length; i++) {
String name = args[i];
Path xmlPath = Vfs.lookup(name);
HashMap<String,Object> argMap = new HashMap<String,Object>();
String []childArgs = new String[argList.size() + 1];
argList.toArray(childArgs);
childArgs[childArgs.length - 1] = name;
argMap.put("arguments", childArgs);
argMap.put("File", Vfs.lookup());
ReadStream is = xmlPath.openRead();
Document doc = null;
try {
if (isStrict)
doc = new Xml().parseDocument(is);
else {
XmlParser parser = new Html();
parser.setEntitiesAsText(true);
doc = parser.parseDocument(is);
}
} finally {
is.close();
}
//Document result = xsl.transform(doc, argMap);
Document result = null;
Path destPath = null;
if (dest != null)
destPath = Vfs.lookup(dest);
else if (suffix != null)
destPath = xmlPath.getParent();
else
destPath = Vfs.lookup("stdout:");
if (suffix != null) {
int p = name.lastIndexOf('.');
if (p == -1) {
System.err.println("suffix missing for `" + name + "'");
System.exit(1);
}
String destName = name.substring(0, p);
if (dest == null) {
p = destName.lastIndexOf('/');
if (p >= 0)
destName = destName.substring(p + 1);
}
if (! destPath.isFile())
destPath = destPath.lookup(destName + '.' + suffix);
else {
System.err.println("illegal output combination");
System.exit(1);
}
}
else if (destPath.isDirectory())
destPath = destPath.lookup(name);
try {
destPath.getParent().mkdirs();
} catch (IOException e) {
}
WriteStream os = destPath.openWrite();
try {
Properties output = stylesheet.getOutputProperties();
String encoding = (String) output.get("encoding");
String mimeType = (String) output.get("mime-type");
String method = (String) output.get("method");
if (encoding == null && (method == null || ! method.equals("html")))
encoding = "UTF-8";
TransformerImpl transformer =
(TransformerImpl) stylesheet.newTransformer();
if (encoding != null)
os.setEncoding(encoding);
transformer.setProperty("caucho.pwd", Vfs.lookup());