use of org.apache.xalan.templates.ElemVariable in project intellij-community by JetBrains.
the class XalanStyleFrame method addVariable.
private void addVariable(ElemVariable variable, boolean global, Collection<Debugger.Variable> variables) {
final Debugger.Variable.Kind kind = variable instanceof ElemParam ? Debugger.Variable.Kind.PARAMETER : Debugger.Variable.Kind.VARIABLE;
assert global == variable.getIsTopLevel() : global + " vs. " + variable.getIsTopLevel() + " (" + variable.getName() + ")";
final String name = variable.getName().getLocalName();
try {
final Value value = kind == Debugger.Variable.Kind.PARAMETER ? // http://youtrack.jetbrains.net/issue/IDEA-78638
eval("$" + variable.getName().toString()) : new XObjectValue(variable.getValue(myTransformer, myCurrentNode));
variables.add(new VariableImpl(name, value, global, kind, variable.getSystemId(), variable.getLineNumber()));
} catch (TransformerException e) {
debug(e);
} catch (Debugger.EvaluationException e) {
debug(e);
}
}
use of org.apache.xalan.templates.ElemVariable in project intellij-community by JetBrains.
the class XalanStyleFrame method collectVariables.
private List<Debugger.Variable> collectVariables() {
final Set<Debugger.Variable> variables = new HashSet<Debugger.Variable>();
ElemTemplateElement p = myCurrentElement;
while (p != null) {
ElemTemplateElement s = p;
while ((s = s.getPreviousSiblingElem()) != null) {
if (s instanceof ElemVariable) {
final ElemVariable variable = (ElemVariable) s;
if (variable.getIsTopLevel()) {
continue;
}
addVariable(variable, false, variables);
}
}
p = p.getParentElem();
}
@SuppressWarnings({ "unchecked", "UseOfObsoleteCollectionType" }) final Vector<ElemVariable> globals = myTransformer.getStylesheet().getVariablesAndParamsComposed();
for (ElemVariable variable : globals) {
addVariable(variable, true, variables);
}
final ArrayList<Debugger.Variable> result = new ArrayList<Debugger.Variable>(variables);
Collections.sort(result, VariableComparator.INSTANCE);
return result;
}
use of org.apache.xalan.templates.ElemVariable in project robovm by robovm.
the class ProcessorExsltFuncResult method startElement.
/**
* Verify that the func:result element does not appear within a variable,
* parameter, or another func:result, and that it belongs to a func:function
* element.
*/
public void startElement(StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) throws SAXException {
String msg = "";
super.startElement(handler, uri, localName, rawName, attributes);
ElemTemplateElement ancestor = handler.getElemTemplateElement().getParentElem();
while (ancestor != null && !(ancestor instanceof ElemExsltFunction)) {
if (ancestor instanceof ElemVariable || ancestor instanceof ElemParam || ancestor instanceof ElemExsltFuncResult) {
msg = "func:result cannot appear within a variable, parameter, or another func:result.";
handler.error(msg, new SAXException(msg));
}
ancestor = ancestor.getParentElem();
}
if (ancestor == null) {
msg = "func:result must appear in a func:function element";
handler.error(msg, new SAXException(msg));
}
}
use of org.apache.xalan.templates.ElemVariable in project robovm by robovm.
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.xalan.templates.ElemVariable in project webtools.sourceediting by eclipse.
the class XalanRootStyleFrame method fillGlobals.
private void fillGlobals(TracerEvent event) {
VariableStack vs = event.m_processor.getXPathContext().getVarStack();
StylesheetRoot sr = event.m_styleNode.getStylesheetRoot();
Vector vars = sr.getVariablesAndParamsComposed();
variables = new HashMap(vars.size());
globals = new ArrayList(vars.size());
int i = vars.size();
while (--i >= 0) {
ElemVariable variable = (ElemVariable) vars.elementAt(i);
XalanVariable xvar = new XalanVariable(this, vs, Variable.GLOBAL_SCOPE, i, variable);
addVariable(xvar);
globals.add(xvar);
}
}
Aggregations