// loop from the top index down to the recursion limit (I don't think
// there's any need to go below that).
for (int i = (nTemplates - 1); i >= m_recursionLimit; i--)
{
ElemTemplate template = getNextMatchOrNamedTemplate(i);
if(null == template)
break;
int loopCount = countLikeTemplates(template, i);
if (loopCount >= m_recursionLimit)
{
// throw new TransformerException("Template nesting too deep. nesting = "+loopCount+
// ", template "+((null == template.getName()) ? "name = " : "match = ")+
// ((null != template.getName()) ? template.getName().toString()
// : template.getMatch().getPatternString()));
String idIs = XSLMessages.createMessage(((null != template.getName()) ? "nameIs" : "matchPatternIs"), null);
Object[] msgArgs = new Object[]{ new Integer(loopCount), idIs,
((null != template.getName()) ? template.getName().toString()
: template.getMatch().getPatternString()) };
String msg = XSLMessages.createMessage("recursionTooDeep", msgArgs);
throw new TransformerException(msg);
}
}