Search in sources :

Example 1 with ElemParam

use of org.apache.xalan.templates.ElemParam 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 2 with ElemParam

use of org.apache.xalan.templates.ElemParam in project j2objc by google.

the class ProcessorGlobalParamDecl method endElement.

/**
   * Receive notification of the end of an element.
   *
   * @param name The element type name.
   * @param attributes The specified or defaulted attributes.
   *
   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
   * @param uri The Namespace URI, or an empty string.
   * @param localName The local name (without prefix), or empty string if not namespace processing.
   * @param rawName The qualified name (with prefix).
   */
public void endElement(StylesheetHandler handler, String uri, String localName, String rawName) throws org.xml.sax.SAXException {
    ElemParam v = (ElemParam) handler.getElemTemplateElement();
    handler.getStylesheet().appendChild(v);
    handler.getStylesheet().setParam(v);
    super.endElement(handler, uri, localName, rawName);
}
Also used : ElemParam(org.apache.xalan.templates.ElemParam)

Example 3 with ElemParam

use of org.apache.xalan.templates.ElemParam 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 4 with ElemParam

use of org.apache.xalan.templates.ElemParam in project j2objc by google.

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 5 with ElemParam

use of org.apache.xalan.templates.ElemParam in project j2objc by google.

the class ProcessorExsltFunction method ancestorIsOk.

/**
   * Verify that a literal result belongs to a result element, a variable, 
   * or a parameter.
   */
boolean ancestorIsOk(ElemTemplateElement child) {
    while (child.getParentElem() != null && !(child.getParentElem() instanceof ElemExsltFunction)) {
        ElemTemplateElement parent = child.getParentElem();
        if (parent instanceof ElemExsltFuncResult || parent instanceof ElemVariable || parent instanceof ElemParam || parent instanceof ElemMessage)
            return true;
        child = parent;
    }
    return false;
}
Also used : ElemVariable(org.apache.xalan.templates.ElemVariable) ElemExsltFuncResult(org.apache.xalan.templates.ElemExsltFuncResult) ElemParam(org.apache.xalan.templates.ElemParam) ElemMessage(org.apache.xalan.templates.ElemMessage) ElemExsltFunction(org.apache.xalan.templates.ElemExsltFunction) ElemTemplateElement(org.apache.xalan.templates.ElemTemplateElement)

Aggregations

ElemParam (org.apache.xalan.templates.ElemParam)7 ElemVariable (org.apache.xalan.templates.ElemVariable)5 ElemExsltFuncResult (org.apache.xalan.templates.ElemExsltFuncResult)4 ElemExsltFunction (org.apache.xalan.templates.ElemExsltFunction)4 ElemTemplateElement (org.apache.xalan.templates.ElemTemplateElement)4 ElemMessage (org.apache.xalan.templates.ElemMessage)2 SAXException (org.xml.sax.SAXException)2 TransformerException (javax.xml.transform.TransformerException)1 Debugger (org.intellij.plugins.xsltDebugger.rt.engine.Debugger)1 Value (org.intellij.plugins.xsltDebugger.rt.engine.Value)1 VariableImpl (org.intellij.plugins.xsltDebugger.rt.engine.local.VariableImpl)1