public void run(JellyContext context, XMLOutput output) throws JellyTagException {
try {
startNamespacePrefixes(output);
} catch (SAXException e) {
throw new JellyTagException("could not start namespace prefixes",e);
}
Tag tag = null;
try {
tag = getTag();
// lets see if we have a dynamic tag
if (tag instanceof StaticTag) {
tag = findDynamicTag(context, (StaticTag) tag);
}
setTag(tag);
} catch (JellyException e) {
throw new JellyTagException(e);
}
try {
if ( tag == null ) {
return;
}
tag.setContext(context);
DynaTag dynaTag = (DynaTag) tag;
// ### probably compiling this to 2 arrays might be quicker and smaller
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
String name = (String) entry.getKey();
Expression expression = (Expression) entry.getValue();
Object value = null;
if ( Expression.class.isAssignableFrom( dynaTag.getAttributeType(name) ) ) {
value = expression;
} else {
value = expression.evaluate(context);
}
dynaTag.setAttribute(name, value);
}
tag.doTag(output);
}
catch (JellyTagException e) {
handleException(e);
}
catch (RuntimeException e) {
handleException(e);
}
try {
endNamespacePrefixes(output);
} catch (SAXException e) {
throw new JellyTagException("could not end namespace prefixes",e);
}
}