* @throws TemplateException
* @throws IOException
*/
public Page transform(ConfigImpl config,SourceFile sf, TagLib[] tlibs, FunctionLib[] flibs) throws TemplateException, IOException {
Page p;
CFMLString cfml;
boolean writeLog=config.getExecutionLogEnabled();
String charset=config.getTemplateCharset();
boolean dotUpper = config.getDotNotationUpperCase();
while(true){
try {
cfml=new CFMLString(sf,charset,writeLog);
p = transform(config,cfml,tlibs,flibs,sf.getResource().lastModified(),dotUpper);
break;
}
catch(ProcessingDirectiveException pde) {
if(pde.getWriteLog()!=null)writeLog=pde.getWriteLog().booleanValue();
if(pde.getDotNotationUpperCase()!=null)dotUpper=pde.getDotNotationUpperCase().booleanValue();
if(!StringUtil.isEmpty(pde.getCharset()))charset=pde.getCharset();
}
}
// if cfc has no component tag or is script without cfscript
if(p.isPage() && ResourceUtil.getExtension(sf.getResource(),"").equalsIgnoreCase(config.getCFCExtension())){
cfml.setPos(0);
TagLibTag tlt;
CFMLString original = cfml;
// try inside a cfscript
tlt = CFMLTransformer.getTLT(original,"script");
String text="<"+tlt.getFullName()+">"+original.getText()+"</"+tlt.getFullName()+">";
cfml=new CFMLString(text,charset,writeLog,sf);
try {
while(true){
if(cfml==null){
cfml=new CFMLString(sf,charset,writeLog);
text="<"+tlt.getFullName()+">"+cfml.getText()+"</"+tlt.getFullName()+">";
cfml=new CFMLString(text,charset,writeLog,sf);
}
try {
p= transform(config,cfml,tlibs,flibs,sf.getResource().lastModified(),dotUpper);
break;
}
catch(ProcessingDirectiveException pde) {
if(pde.getWriteLog()!=null)writeLog=pde.getWriteLog().booleanValue();
if(pde.getDotNotationUpperCase()!=null)dotUpper=pde.getDotNotationUpperCase().booleanValue();
if(!StringUtil.isEmpty(pde.getCharset()))charset=pde.getCharset();
cfml=null;
}
}
}
catch (ComponentTemplateException e) {
throw e.getTemplateException();
}
catch (TemplateException e) {
//print.printST(e);
}
// try inside a component
if(p.isPage()){
tlt = CFMLTransformer.getTLT(original,"component");
text="<"+tlt.getFullName()+">"+original.getText()+"</"+tlt.getFullName()+">";
cfml=new CFMLString(text,charset,writeLog,sf);
while(true){
if(cfml==null){
cfml=new CFMLString(sf,charset,writeLog);
text="<"+tlt.getFullName()+">"+cfml.getText()+"</"+tlt.getFullName()+">";
cfml=new CFMLString(text,charset,writeLog,sf);
}
try {
p= transform(config,cfml,tlibs,flibs,sf.getResource().lastModified(),dotUpper);
break;
}