in core/src/main/java/org/apache/commons/jelly/impl/StaticTagScript.java [69:140]
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;
try {
tag = getTag(context);
// lets see if we have a dynamic tag
if (tag instanceof StaticTag) {
tag = findDynamicTag(context, (StaticTag) tag);
}
setTag(tag, context);
} catch (JellyException e) {
throw new JellyTagException(e);
}
URL rootURL = context.getRootURL();
URL currentURL = context.getCurrentURL();
try {
if (tag == null) {
return;
}
tag.setContext(context);
setContextURLs(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();
if (name.indexOf(':') != -1)
name = name.substring(name.indexOf(':') + 1);
ExpressionAttribute expat = (ExpressionAttribute) entry.getValue();
Expression expression = expat.exp;
Object value;
if (Expression.class.isAssignableFrom(dynaTag.getAttributeType(name))) {
value = expression;
} else {
value = expression.evaluate(context);
}
if (expat.prefix != null && expat.prefix.length() > 0 && tag instanceof StaticTag) {
((StaticTag) dynaTag).setAttribute(name, expat.prefix, expat.nsURI, value);
} else {
dynaTag.setAttribute(name, value);
}
}
tag.doTag(output);
} catch (JellyTagException e) {
handleException(e);
} catch (RuntimeException e) {
handleException(e);
} finally {
context.setCurrentURL(currentURL);
context.setRootURL(rootURL);
}
try {
endNamespacePrefixes(output);
} catch (SAXException e) {
throw new JellyTagException("could not end namespace prefixes", e);
}
}