/** * This function is called after everything else has been recomposed, and allows the template to * set remaining values that may be based on some other property that depends on recomposition. */ public void compose(StylesheetRoot sroot) throws TransformerException { // See if we can reduce an RTF to a select with a string expression. if (null == m_selectPattern && sroot.getOptimizer()) { XPath newSelect = rewriteChildToExpression(this); if (null != newSelect) m_selectPattern = newSelect; } StylesheetRoot.ComposeState cstate = sroot.getComposeState(); // This should be done before addVariableName, so we don't have visibility // to the variable now being defined. java.util.Vector vnames = cstate.getVariableNames(); if (null != m_selectPattern) m_selectPattern.fixupVariables(vnames, cstate.getGlobalsSize()); // Only add the variable if this is not a global. If it is a global, // it was already added by stylesheet root. if (!(m_parentNode instanceof Stylesheet) && m_qname != null) { m_index = cstate.addVariableName(m_qname) - cstate.getGlobalsSize(); } else if (m_parentNode instanceof Stylesheet) { // If this is a global, then we need to treat it as if it's a xsl:template, // and count the number of variables it contains. So we set the count to // zero here. cstate.resetStackFrameSize(); } // This has to be done after the addVariableName, so that the variable // pushed won't be immediately popped again in endCompose. super.compose(sroot); }