} catch (SAXException e) {
}
}
*/
Path destDir = null;
if (dest != null)
destDir = Vfs.lookup(dest);
else if (suffix == null)
destDir = Vfs.lookup("stdout:");
if (args.length - i > 1 && (dest == null || destDir.isFile()) &&
suffix == null) {
System.err.println("multiple sources require a destination directory");
System.exit(1);
}
try {
MergePath stylePath = new MergePath();
stylePath.addMergePath(Vfs.lookup(xslName).getParent());
stylePath.addMergePath(Vfs.lookup());
stylePath.addMergePath(CauchoSystem.getResinHome().lookup("xsl"));
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader instanceof DynamicClassLoader) {
DynamicClassLoader dynLoader
= (DynamicClassLoader) loader;
String resourcePath = dynLoader.getResourcePathSpecificFirst();
stylePath.addClassPath(resourcePath);
}
// stylePath.addClassPath(
/*
Path []stylePath = new Path[] {
Pwd.lookup(xslName).getParent(),
Pwd.lookup(),
CauchoSystem.getResinHome().lookup("xsl")};
*/
Path []scriptPath = new Path[] {
Vfs.lookup(),
Vfs.lookup(xslName).getParent(),
CauchoSystem.getResinHome().lookup("scripts")
};
Path xslPath = stylePath.lookup(xslName);
if (xslPath == null) {
System.out.println("can't find `" + xslName + "'");
System.exit(1);
}
AbstractStylesheetFactory xsl;
if (isStrict)
xsl = new Xsl();
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");