/** * Create a psuedo variable reference that will represent the * shared redundent XPath, for a local reduction. * * @param uniquePseudoVarName The name of the new variable. * @param stylesheetRoot The broadest scope of where the variable * should be inserted, which must be a StylesheetRoot element in this case. * @param lpi The LocationPathIterator that the variable should represent. * @return null if the decl was not created, otherwise the new Pseudo var * element. */ protected ElemVariable createGlobalPseudoVarDecl(QName uniquePseudoVarName, StylesheetRoot stylesheetRoot, LocPathIterator lpi) throws org.w3c.dom.DOMException { ElemVariable psuedoVar = new ElemVariable(); psuedoVar.setIsTopLevel(true); XPath xpath = new XPath(lpi); psuedoVar.setSelect(xpath); psuedoVar.setName(uniquePseudoVarName); Vector globalVars = stylesheetRoot.getVariablesAndParamsComposed(); psuedoVar.setIndex(globalVars.size()); globalVars.addElement(psuedoVar); return psuedoVar; }
/** * 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 { super.compose(sroot); m_qnameID = sroot.getComposeState().getQNameID(m_qname); int parentToken = m_parentNode.getXSLToken(); if (parentToken == Constants.ELEMNAME_TEMPLATE || parentToken == Constants.EXSLT_ELEMNAME_FUNCTION) ((ElemTemplate)m_parentNode).m_inArgsSize++; }
/** * Recompose the top level variable and parameter declarations. * * @param elemVar A top level variable or parameter to be added to the Vector. */ void recomposeVariables(ElemVariable elemVar) { // Don't overide higher priority variable if (getVariableOrParamComposed(elemVar.getName()) == null) { elemVar.setIsTopLevel(true); // Mark as a top-level variable or param elemVar.setIndex(m_variables.size()); m_variables.addElement(elemVar); } }
/** * Add a child to the child list. If the select attribute * is present, an error will be raised. * * @param elem New element to append to this element's children list * * @return null if the select attribute was present, otherwise the * child just added to the child list */ public ElemTemplateElement appendChild(ElemTemplateElement elem) { // cannot have content and select if (m_selectPattern != null) { error(XSLTErrorResources.ER_CANT_HAVE_CONTENT_AND_SELECT, new Object[]{"xsl:" + this.getNodeName()}); return null; } return super.appendChild(elem); }
/** * Get an "xsl:param" property. * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a> * * @param qname non-null reference to qualified name of the parameter. * * @return ElemParam with the given name in the list or null */ public ElemParam getParam(QName qname) { if (null != m_topLevelVariables) { int n = getVariableOrParamCount(); for (int i = 0; i < n; i++) { ElemVariable var = getVariableOrParam(i); if((var.getXSLToken() == Constants.ELEMNAME_PARAMVARIABLE) && (var.getName().equals(qname))) return (ElemParam)var; } } return null; }
if(null == var) return 0; uniquePseudoVarName = var.getName(); paths.setElementAt(var.getSelect(), firstOccuranceIndex); numPathsFound++; if(null == var) return 0; uniquePseudoVarName = var.getName(); changeToVarRef(uniquePseudoVarName, firstOccuranceOwner, paths, psuedoVarRecipient); paths.setElementAt(var.getSelect(), firstOccuranceIndex); numPathsFound++;
/** * 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 = ElemVariable.rewriteChildToExpression(this); if(null != newSelect) m_selectPattern = newSelect; } m_qnameID = sroot.getComposeState().getQNameID(m_qname); super.compose(sroot); java.util.Vector vnames = sroot.getComposeState().getVariableNames(); if(null != m_selectPattern) m_selectPattern.fixupVariables(vnames, sroot.getComposeState().getGlobalsSize()); // m_index must be resolved by ElemApplyTemplates and ElemCallTemplate! }
/** * Execute a variable declaration and push it onto the variable stack. * @see <a href="http://www.w3.org/TR/xslt#variables">variables in XSLT Specification</a> * * @param transformer non-null reference to the the current transform-time state. * * @throws TransformerException */ public void execute(TransformerImpl transformer) throws TransformerException { int sourceNode = transformer.getXPathContext().getCurrentNode(); XObject var = getValue(transformer, sourceNode); // transformer.getXPathContext().getVarStack().pushVariable(m_qname, var); transformer.getXPathContext().getVarStack().setLocalVariable(m_index, var); }
/** * For support of literal objects in xpaths. * * @param xctxt The XPath execution context. * * @return This object. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { Expression expr = ((ElemVariable)m_obj).getSelect().getExpression(); XObject xobj = expr.execute(xctxt); xobj.allowDetachToRelease(false); return xobj; }
ComposeState() { int size = m_variables.size(); for (int i = 0; i < size; i++) { ElemVariable ev = (ElemVariable)m_variables.elementAt(i); m_variableNames.addElement(ev.getName()); } }
/** * Add a child to the child list. If the select attribute * is present, an error will be raised. * * @param elem New element to append to this element's children list * * @return null if the select attribute was present, otherwise the * child just added to the child list */ public ElemTemplateElement appendChild(ElemTemplateElement elem) { // cannot have content and select if (m_selectPattern != null) { error(XSLTErrorResources.ER_CANT_HAVE_CONTENT_AND_SELECT, new Object[]{"xsl:" + this.getNodeName()}); return null; } return super.appendChild(elem); }
if (children.item(i) instanceof ElemParam) { ElemParam param = (ElemParam)children.item(i); vars.setLocalVariable(param.getIndex(), args[i], nextFrame);
/** * Recompose the top level variable and parameter declarations. * * @param elemVar A top level variable or parameter to be added to the Vector. */ void recomposeVariables(ElemVariable elemVar) { // Don't overide higher priority variable if (getVariableOrParamComposed(elemVar.getName()) == null) { elemVar.setIsTopLevel(true); // Mark as a top-level variable or param elemVar.setIndex(m_variables.size()); m_variables.addElement(elemVar); } }
/** * Get an "xsl:variable" property. * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a> * * @param qname Qualified name of the xsl:variable to get * * @return reference to the variable named by qname, or null if not found. */ public ElemVariable getVariable(QName qname) { if (null != m_topLevelVariables) { int n = getVariableOrParamCount(); for (int i = 0; i < n; i++) { ElemVariable var = getVariableOrParam(i); if((var.getXSLToken() == Constants.ELEMNAME_VARIABLE) && (var.getName().equals(qname))) return var; } } return null; }
/** * Add a child to the child list. If the select attribute * is present, an error will be raised. * * @param elem New element to append to this element's children list * * @return null if the select attribute was present, otherwise the * child just added to the child list */ public ElemTemplateElement appendChild(ElemTemplateElement elem) { // cannot have content and select if (m_selectPattern != null) { error(XSLTErrorResources.ER_CANT_HAVE_CONTENT_AND_SELECT, new Object[]{"xsl:" + this.getNodeName()}); return null; } return super.appendChild(elem); }
if(null == var) return 0; uniquePseudoVarName = var.getName(); paths.setElementAt(var.getSelect(), firstOccuranceIndex); numPathsFound++; if(null == var) return 0; uniquePseudoVarName = var.getName(); changeToVarRef(uniquePseudoVarName, firstOccuranceOwner, paths, psuedoVarRecipient); paths.setElementAt(var.getSelect(), firstOccuranceIndex); numPathsFound++;
/** * 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 = ElemVariable.rewriteChildToExpression(this); if(null != newSelect) m_selectPattern = newSelect; } m_qnameID = sroot.getComposeState().getQNameID(m_qname); super.compose(sroot); java.util.Vector vnames = sroot.getComposeState().getVariableNames(); if(null != m_selectPattern) m_selectPattern.fixupVariables(vnames, sroot.getComposeState().getGlobalsSize()); // m_index must be resolved by ElemApplyTemplates and ElemCallTemplate! }
/** * Execute a variable declaration and push it onto the variable stack. * @see <a href="http://www.w3.org/TR/xslt#variables">variables in XSLT Specification</a> * * @param transformer non-null reference to the the current transform-time state. * * @throws TransformerException */ public void execute(TransformerImpl transformer) throws TransformerException { if (transformer.getDebug()) transformer.getTraceManager().fireTraceEvent(this); int sourceNode = transformer.getXPathContext().getCurrentNode(); XObject var = getValue(transformer, sourceNode); // transformer.getXPathContext().getVarStack().pushVariable(m_qname, var); transformer.getXPathContext().getVarStack().setLocalVariable(m_index, var); if (transformer.getDebug()) transformer.getTraceManager().fireTraceEndEvent(this); }