Search in sources :

Example 1 with ElemVariable

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);
    }
}
Also used : Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) VariableImpl(org.intellij.plugins.xsltDebugger.rt.engine.local.VariableImpl) ElemVariable(org.apache.xalan.templates.ElemVariable) ElemParam(org.apache.xalan.templates.ElemParam) Value(org.intellij.plugins.xsltDebugger.rt.engine.Value) TransformerException(javax.xml.transform.TransformerException)

Example 2 with ElemVariable

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;
}
Also used : Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) ElemVariable(org.apache.xalan.templates.ElemVariable) ElemVariable(org.apache.xalan.templates.ElemVariable) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Example 3 with ElemVariable

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));
    }
}
Also used : ElemVariable(org.apache.xalan.templates.ElemVariable) ElemExsltFuncResult(org.apache.xalan.templates.ElemExsltFuncResult) ElemParam(org.apache.xalan.templates.ElemParam) ElemExsltFunction(org.apache.xalan.templates.ElemExsltFunction) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement) SAXException(org.xml.sax.SAXException)

Example 4 with ElemVariable

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);
    }
}
Also used : VariableStack(org.apache.xpath.VariableStack) ElemVariable(org.apache.xalan.templates.ElemVariable) XUnresolvedVariable(org.apache.xalan.templates.XUnresolvedVariable) StylesheetRoot(org.apache.xalan.templates.StylesheetRoot) XPathContext(org.apache.xpath.XPathContext) Vector(java.util.Vector) NodeVector(org.apache.xml.utils.NodeVector) XObject(org.apache.xpath.objects.XObject)

Example 5 with ElemVariable

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);
    }
}
Also used : VariableStack(org.apache.xpath.VariableStack) ElemVariable(org.apache.xalan.templates.ElemVariable) StylesheetRoot(org.apache.xalan.templates.StylesheetRoot) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Vector(java.util.Vector)

Aggregations

ElemVariable (org.apache.xalan.templates.ElemVariable)13 ElemTemplateElement (org.apache.xalan.templates.ElemTemplateElement)6 ElemParam (org.apache.xalan.templates.ElemParam)5 Vector (java.util.Vector)4 ElemExsltFuncResult (org.apache.xalan.templates.ElemExsltFuncResult)4 ElemExsltFunction (org.apache.xalan.templates.ElemExsltFunction)4 StylesheetRoot (org.apache.xalan.templates.StylesheetRoot)4 VariableStack (org.apache.xpath.VariableStack)4 NodeVector (org.apache.xml.utils.NodeVector)3 XObject (org.apache.xpath.objects.XObject)3 ElemMessage (org.apache.xalan.templates.ElemMessage)2 XUnresolvedVariable (org.apache.xalan.templates.XUnresolvedVariable)2 XPathContext (org.apache.xpath.XPathContext)2 Debugger (org.intellij.plugins.xsltDebugger.rt.engine.Debugger)2 SAXException (org.xml.sax.SAXException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TransformerException (javax.xml.transform.TransformerException)1 TracerEvent (org.apache.xalan.trace.TracerEvent)1 QName (org.apache.xml.utils.QName)1