001 /* 002 @license.text@ 003 */ 004 package biz.hammurapi.render.dom; 005 006 import java.io.File; 007 008 import org.apache.tools.ant.Task; 009 010 /** 011 * @author Pavel Vlasov 012 * @version $Revision: 1.3 $ 013 */ 014 public class StyleCompiler extends Task { 015 final static String POSTFIX="Translet"; 016 final static char PROFILE_SEPARATOR='!'; 017 final static char TRANSLET_PROFILE_SEPARATOR='_'; 018 019 /** 020 * Destination directory 021 * @ant.required 022 * @param destDir 023 */ 024 public void setDestDir(File destDir) { 025 } 026 /** 027 * Source directory 028 * @ant.required 029 * @param dir 030 */ 031 public void setDir(File dir) { 032 } 033 034 // public void execute() throws BuildException { 035 // if (dir==null) { 036 // throw new BuildException("Dir attribute is mandatory"); 037 // } 038 // if (destDir==null) { 039 // throw new BuildException("DestDir attribute is mandatory"); 040 // } 041 // FileSet fileSet=new FileSet(); 042 // fileSet.setDir(dir); 043 // fileSet.setIncludes("**/*.xsl,**/*.xslt"); 044 // String[] files = fileSet.getDirectoryScanner(getProject()).getIncludedFiles(); 045 // for (int i=0; i<files.length; i++) { 046 // org.apache.xalan.xsltc.compiler.XSLTC xsltc=new org.apache.xalan.xsltc.compiler.XSLTC(); 047 // xsltc.init(); 048 // xsltc.setDestDirectory(destDir.getAbsolutePath()); 049 // 050 // int idx=files[i].lastIndexOf(File.separator); 051 // xsltc.setPackageName(idx==-1 ? "" : files[i].substring(0, idx).replace(File.separatorChar, '.')); 052 // String className = idx==-1 ? files[i] : files[i].substring(idx+1); 053 // idx=className.lastIndexOf('.'); 054 // if (idx!=-1) { 055 // className=className.substring(0, idx); 056 // } 057 // idx=className.indexOf(PROFILE_SEPARATOR); 058 // if (idx==-1) { 059 // className+=POSTFIX; 060 // } else { 061 // className=className.substring(0, idx)+POSTFIX+TRANSLET_PROFILE_SEPARATOR+className.substring(idx+1); 062 // } 063 // log("Compiling "+files[i]+" into "+className, Project.MSG_INFO); 064 // xsltc.setClassName(className); 065 // try { 066 // boolean result = xsltc.compile(new InputSource(new FileInputStream(new File(dir, files[i]))), null); 067 // xsltc.printWarnings(); 068 // if (!result) { 069 // xsltc.printErrors(); 070 // } 071 // } catch (FileNotFoundException e) { 072 // throw new BuildException(e); 073 // } 074 // } 075 // } 076 077 public static void main(String[] args) { 078 } 079 }