//int column=data.cfml.getColumn();
int start=data.cfml.getPos();
data.cfml.next();
// read in namesapce of tag
TagLib tagLib=nameSpace(data);
// return if no matching tag lib
if(tagLib==null) {
data.cfml.previous();
return false;
}
// Get matching tag from tag lib
String strNameNormal=identifier(data.cfml,false);
if(strNameNormal==null) {
data.cfml.setPos((data.cfml.getPos()-tagLib.getNameSpaceAndSeparator().length())-1);
return false;
}
String strName=strNameNormal.toLowerCase();
String appendix=null;
TagLibTag tagLibTag=tagLib.getTag(strName);
// get taglib
if(tagLibTag==null) {
tagLibTag=tagLib.getAppendixTag(strName);
if(tagLibTag==null) {
if(tagLib.getIgnoreUnknowTags()){
data.cfml.setPos(start);
return false;
}
throw new TemplateException(data.cfml,"undefined tag ["+tagLib.getNameSpaceAndSeparator()+strName+"]");
}
appendix=StringUtil.removeStartingIgnoreCase(strNameNormal,tagLibTag.getName());
}
// CFXD Element
Tag tag;
try {
tag = tagLibTag.getTag(line,data.cfml.getPosition());
}
catch (Exception e) {
throw new TemplateException(data.cfml,e);
}
parent.addStatement(tag);
// get tag from tag library
if(appendix!=null) {
tag.setAppendix(appendix);
tag.setFullname(tagLibTag.getFullName().concat(appendix));
}
else {
tag.setFullname(tagLibTag.getFullName());
}
if(tag.getFullname().equalsIgnoreCase("cfcomponent"))data.page.setIsComponent(true); // MUST to hardcoded, to better
else if(tag.getFullname().equalsIgnoreCase("cfinterface"))data.page.setIsInterface(true); // MUST to hardcoded, to better
tag.setTagLibTag(tagLibTag);
comment(data.cfml,true);
// Tag Translator Evaluator
if(tagLibTag.hasTteClass()) {
data.ep.add(tagLibTag,tag,data.flibs,data.cfml);
}
//get Attributes
attributes(data,tagLibTag,tag);
if(tagLibTag.hasAttributeEvaluator()) {
try {
tagLibTag=tagLibTag.getAttributeEvaluator().evaluate(tagLibTag,tag);
} catch (AttributeEvaluatorException e) {
throw new TemplateException(data.cfml, e);
}
}
// End of begin Tag
// TODO muss erlaubt sein
if(data.cfml.forwardIfCurrent('>')) {
hasBody=tagLibTag.getHasBody();
}
else if(data.cfml.forwardIfCurrent('/','>')) {
if(tagLibTag.getHasBody())tag.setBody(new BodyBase());
}
else {
throw createTemplateException(data.cfml, "tag ["+tagLibTag.getFullName()+"] is not closed",tagLibTag);
}
// Body
if(hasBody) {
// get Body
if(tagLibTag.isTagDependent()) {
// get TagDependentBodyTransformer
TagDependentBodyTransformer tdbt=null;
try {
tdbt=tagLibTag.getBodyTransformer();
} catch (TagLibException e) {
throw new TemplateException(data.cfml,e);
}
if(tdbt==null) throw createTemplateException(data.cfml,"Tag dependent body Transformer is invalid for Tag ["+tagLibTag.getFullName()+"]",tagLibTag);
tdbt.transform(data.page,this,data.ep,data.flibs,tag,tagLibTag,data.scriptTags,data.cfml,data.settings);
// get TagLib of end Tag
if(!data.cfml.forwardIfCurrent("</")) {
// MUST this is a patch, do a more proper implementation
TemplateException te = new TemplateException(data.cfml,"invalid construct");
if(tdbt instanceof CFMLScriptTransformer && ASMUtil.containsComponent(tag.getBody())) {
throw new CFMLScriptTransformer.ComponentTemplateException(te);
}
throw te;
}
TagLib tagLibEnd=nameSpace(data);
// same NameSpace
if(!(tagLibEnd!=null && tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())))
throw new TemplateException(data.cfml,"invalid construct");
// get end Tag
String strNameEnd=identifier(data.cfml,true).toLowerCase();
// not the same name Tag
if(!strName.equals(strNameEnd)) {
data.cfml.setPos(start);
throw new TemplateException(data.cfml,"Start and End Tag has not the same Name ["+tagLib.getNameSpaceAndSeparator()+strName+"-"+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"]");
}
data.cfml.removeSpace();
if(!data.cfml.forwardIfCurrent('>'))
throw new TemplateException(data.cfml,"End Tag ["+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] not closed");
}
else {
// get body of Tag
BodyBase body=new BodyBase();
body.setParent(tag);
//tag.setBody(body);
//parseExpression=(tagLibTag.getParseBody())?true:parseExpression;
if(tagLibTag.getParseBody())parseExpression=true;
while(true) {
// Load Expession Transformer from TagLib
ExprTransformer transfomer=null;
if(parseExpression) {
try {
transfomer = tagLibTag.getTagLib().getExprTransfomer();
} catch (TagLibException e) {
throw new TemplateException(data.cfml,e);
}
}
// call body
body(data,body,parseExpression,transfomer);
// no End Tag
if(data.cfml.isAfterLast()) {
if(tagLibTag.isBodyReq()) {
data.cfml.setPos(start);
throw createTemplateException(data.cfml,"No matching end tag found for tag ["+tagLibTag.getFullName()+"]",tagLibTag);
}
body.moveStatmentsTo(parent);
return executeEvaluator(data,tagLibTag, tag);
}
// Invalid Construct
int posBeforeEndTag=data.cfml.getPos();
if(!data.cfml.forwardIfCurrent('<','/'))
throw createTemplateException(data.cfml,"Missing end tag for ["+tagLibTag.getFullName()+"]",tagLibTag);
// get TagLib of end Tag
int _start = data.cfml.getPos();
TagLib tagLibEnd=nameSpace(data);
// same NameSpace
if(tagLibEnd!=null) {
String strNameEnd="";
//railo.print.ln(data.cfml.getLine()+" - "+data.cfml.getColumn()+" - "+tagLibEnd.getNameSpaceAndSeperator()+".equals("+tagLib.getNameSpaceAndSeperator()+")");
if(tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())) {
// get end Tag
strNameEnd=identifier(data.cfml,true).toLowerCase();
// not the same name Tag
// new part
data.cfml.removeSpace();
if(strName.equals(strNameEnd)) {
if(!data.cfml.forwardIfCurrent('>'))
throw new TemplateException(data.cfml,"End Tag ["+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] not closed");
break;
}
}
// new part
if(tagLibTag.isBodyReq()) {
TagLibTag endTag = tagLibEnd.getTag(strNameEnd);
if(endTag!=null && !endTag.getHasBody())
throw new TemplateException(data.cfml,
"End Tag ["+
tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] is not allowed, for this tag only a Start Tag is allowed");
data.cfml.setPos(start);
if(tagLibEnd.getIgnoreUnknowTags() && (tagLibEnd.getTag(strNameEnd))==null){
data.cfml.setPos(_start);
}
else throw new TemplateException(data.cfml,
"Start and End Tag has not the same Name ["+
tagLib.getNameSpaceAndSeparator()+strName+"-"+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"]");
}
else {
body.moveStatmentsTo(parent);
data.cfml.setPos(posBeforeEndTag);
return executeEvaluator(data,tagLibTag, tag);