/*
* create an InternalContextAdapter to carry the user Context down
* into the rendering engine. Set the template name and render()
*/
InternalContextAdapterImpl ica = new InternalContextAdapterImpl( context );
/**
* Set the macro libraries
*/
ica.setMacroLibraries(macroLibraries);
if (macroLibraries != null)
{
for (int i = 0; i < macroLibraries.size(); i++)
{
/**
* Build the macro library
*/
try
{
rsvc.getTemplate((String) macroLibraries.get(i));
}
catch (ResourceNotFoundException re)
{
/*
* the macro lib wasn't found. Note it and throw
*/
rsvc.getLog().error("template.merge(): " +
"cannot find template " +
(String) macroLibraries.get(i));
throw re;
}
catch (ParseErrorException pe)
{
/*
* the macro lib was found, but didn't parse - syntax error
* note it and throw
*/
rsvc.getLog().error("template.merge(): " +
"syntax error in template " +
(String) macroLibraries.get(i) + ".");
throw pe;
}
catch (Exception e)
{
throw new RuntimeException("Template.merge(): parse failed in template " +
(String) macroLibraries.get(i) + ".", e);
}
}
}
try
{
ica.pushCurrentTemplateName( name );
ica.setCurrentResource( this );
( (SimpleNode) data ).render( ica, writer);
}
finally
{
/*
* lets make sure that we always clean up the context
*/
ica.popCurrentTemplateName();
ica.setCurrentResource( null );
}
}
else
{
/*