*
* @param template
*/
public void setTemplate(ElemTemplate template)
{
XPath matchXPath = template.getMatch();
if (null == template.getName() && null == matchXPath)
{
template.error(XSLTErrorResources.ER_NEED_NAME_OR_MATCH_ATTRIB,
new Object[]{ "xsl:template" });
}
if (null != template.getName())
{
ElemTemplate existingTemplate = (ElemTemplate) m_namedTemplates.get(template.getName());
if (null == existingTemplate)
{
m_namedTemplates.put(template.getName(), template);
}
else
{
int existingPrecedence =
existingTemplate.getStylesheetComposed().getImportCountComposed();
int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
if (newPrecedence > existingPrecedence)
{
// This should never happen
m_namedTemplates.put(template.getName(), template);
}
else if (newPrecedence == existingPrecedence)
template.error(XSLTErrorResources.ER_DUPLICATE_NAMED_TEMPLATE,
new Object[]{ template.getName() });
}
}
if (null != matchXPath)
{
Expression matchExpr = matchXPath.getExpression();
if (matchExpr instanceof StepPattern)
{
insertPatternInTable((StepPattern) matchExpr, template);
}