use of org.apache.xpath.VariableStack in project robovm by robovm.
the class FilterExprIteratorSimple method executeFilterExpr.
/**
* Execute the expression. Meant for reuse by other FilterExpr iterators
* that are not derived from this object.
*/
public static XNodeSet executeFilterExpr(int context, XPathContext xctxt, PrefixResolver prefixResolver, boolean isTopLevel, int stackFrame, Expression expr) throws org.apache.xml.utils.WrappedRuntimeException {
PrefixResolver savedResolver = xctxt.getNamespaceContext();
XNodeSet result = null;
try {
xctxt.pushCurrentNode(context);
xctxt.setNamespaceContext(prefixResolver);
if (isTopLevel) {
// System.out.println("calling m_expr.execute(getXPathContext())");
VariableStack vars = xctxt.getVarStack();
// These three statements need to be combined into one operation.
int savedStart = vars.getStackFrame();
vars.setStackFrame(stackFrame);
result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
result.setShouldCacheNodes(true);
// These two statements need to be combined into one operation.
vars.setStackFrame(savedStart);
} else
result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
} catch (javax.xml.transform.TransformerException se) {
// TODO: Fix...
throw new org.apache.xml.utils.WrappedRuntimeException(se);
} finally {
xctxt.popCurrentNode();
xctxt.setNamespaceContext(savedResolver);
}
return result;
}
use of org.apache.xpath.VariableStack in project j2objc by google.
the class ElemParam method execute.
/**
* 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 {
VariableStack vars = transformer.getXPathContext().getVarStack();
if (!vars.isLocalSet(m_index)) {
int sourceNode = transformer.getXPathContext().getCurrentNode();
XObject var = getValue(transformer, sourceNode);
// transformer.getXPathContext().getVarStack().pushVariable(m_qname, var);
transformer.getXPathContext().getVarStack().setLocalVariable(m_index, var);
}
}
use of org.apache.xpath.VariableStack in project j2objc by google.
the class TransformerImpl method pushGlobalVars.
/**
* Internal -- push the global variables from the Stylesheet onto
* the context's runtime variable stack.
* <p>If we encounter a variable
* that is already defined in the variable stack, we ignore it. This
* is because the second variable definition will be at a lower import
* precedence. Presumably, global"variables at the same import precedence
* with the same name will have been caught during the recompose process.
* <p>However, if we encounter a parameter that is already defined in the
* variable stack, we need to see if this is a parameter whose value was
* supplied by a setParameter call. If so, we need to "receive" the one
* already in the stack, ignoring this one. If it is just an earlier
* xsl:param or xsl:variable definition, we ignore it using the same
* reasoning as explained above for the variable.
*
* @param contextNode The root of the source tree, can't be null.
*
* @throws TransformerException
*/
protected void pushGlobalVars(int contextNode) throws TransformerException {
XPathContext xctxt = m_xcontext;
VariableStack vs = xctxt.getVarStack();
StylesheetRoot sr = getStylesheet();
Vector vars = sr.getVariablesAndParamsComposed();
int i = vars.size();
vs.link(i);
while (--i >= 0) {
ElemVariable v = (ElemVariable) vars.elementAt(i);
// XObject xobj = v.getValue(this, contextNode);
XObject xobj = new XUnresolvedVariable(v, contextNode, this, vs.getStackFrame(), 0, true);
if (null == vs.elementAt(i))
vs.setGlobalVariable(i, xobj);
}
}
use of org.apache.xpath.VariableStack in project j2objc by google.
the class TransformerImpl method clearParameters.
/**
* Reset the parameters to a null list.
*/
public void clearParameters() {
synchronized (m_reentryGuard) {
VariableStack varstack = new VariableStack();
m_xcontext.setVarStack(varstack);
m_userParams = null;
}
}
use of org.apache.xpath.VariableStack in project j2objc by google.
the class ElemCallTemplate method execute.
/**
* Invoke a named template.
* @see <a href="http://www.w3.org/TR/xslt#named-templates">named-templates 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 (null != m_template) {
XPathContext xctxt = transformer.getXPathContext();
VariableStack vars = xctxt.getVarStack();
int thisframe = vars.getStackFrame();
int nextFrame = vars.link(m_template.m_frameSize);
// so that the default param evaluation will work correctly.
if (m_template.m_inArgsSize > 0) {
vars.clearLocalSlots(0, m_template.m_inArgsSize);
if (null != m_paramElems) {
int currentNode = xctxt.getCurrentNode();
vars.setStackFrame(thisframe);
int size = m_paramElems.length;
for (int i = 0; i < size; i++) {
ElemWithParam ewp = m_paramElems[i];
if (ewp.m_index >= 0) {
XObject obj = ewp.getValue(transformer, currentNode);
// Note here that the index for ElemWithParam must have been
// statically made relative to the xsl:template being called,
// NOT this xsl:template.
vars.setLocalVariable(ewp.m_index, obj, nextFrame);
}
}
vars.setStackFrame(nextFrame);
}
}
SourceLocator savedLocator = xctxt.getSAXLocator();
try {
xctxt.setSAXLocator(m_template);
// template.executeChildTemplates(transformer, sourceNode, mode, true);
transformer.pushElemTemplateElement(m_template);
m_template.execute(transformer);
} finally {
transformer.popElemTemplateElement();
xctxt.setSAXLocator(savedLocator);
// When we entered this function, the current
// frame buffer (cfb) index in the variable stack may
// have been manually set. If we just call
// unlink(), however, it will restore the cfb to the
// previous link index from the link stack, rather than
// the manually set cfb. So,
// the only safe solution is to restore it back
// to the same position it was on entry, since we're
// really not working in a stack context here. (Bug4218)
vars.unlink(thisframe);
}
} else {
transformer.getMsgMgr().error(this, XSLTErrorResources.ER_TEMPLATE_NOT_FOUND, //"Could not find template named: '"+templateName+"'");
new Object[] { m_templateName });
}
}
Aggregations