Search in sources :

Example 1 with StylesheetRoot

use of org.apache.xalan.templates.StylesheetRoot in project robovm by robovm.

the class ProcessorLRE method getStylesheetRoot.

/**
   * This method could be over-ridden by a class that extends this class.
   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
   * @return an object that represents the stylesheet element.
   */
protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException {
    StylesheetRoot stylesheet;
    stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener());
    if (handler.getStylesheetProcessor().isSecureProcessing())
        stylesheet.setSecureProcessing(true);
    return stylesheet;
}
Also used : StylesheetRoot(org.apache.xalan.templates.StylesheetRoot)

Example 2 with StylesheetRoot

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

use of org.apache.xalan.templates.StylesheetRoot 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)

Example 4 with StylesheetRoot

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

the class TransformerImpl method setParameter.

/**
 * Set a parameter for the templates.
 *
 * @param name The name of the parameter.
 * @param namespace The namespace of the parameter.
 * @param value The value object.  This can be any valid Java object
 * -- it's up to the processor to provide the proper
 * coersion to the object, or simply pass it on for use
 * in extensions.
 */
public void setParameter(String name, String namespace, Object value) {
    VariableStack varstack = getXPathContext().getVarStack();
    QName qname = new QName(namespace, name);
    XObject xobject = XObject.create(value, getXPathContext());
    StylesheetRoot sroot = m_stylesheetRoot;
    Vector vars = sroot.getVariablesAndParamsComposed();
    int i = vars.size();
    while (--i >= 0) {
        ElemVariable variable = (ElemVariable) vars.elementAt(i);
        if (variable.getXSLToken() == Constants.ELEMNAME_PARAMVARIABLE && variable.getName().equals(qname)) {
            varstack.setGlobalVariable(i, xobject);
        }
    }
}
Also used : VariableStack(org.apache.xpath.VariableStack) ElemVariable(org.apache.xalan.templates.ElemVariable) StylesheetRoot(org.apache.xalan.templates.StylesheetRoot) QName(org.apache.xml.utils.QName) Vector(java.util.Vector) NodeVector(org.apache.xml.utils.NodeVector) XObject(org.apache.xpath.objects.XObject)

Example 5 with StylesheetRoot

use of org.apache.xalan.templates.StylesheetRoot 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);
    }
}
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)

Aggregations

StylesheetRoot (org.apache.xalan.templates.StylesheetRoot)10 Vector (java.util.Vector)4 ElemVariable (org.apache.xalan.templates.ElemVariable)4 VariableStack (org.apache.xpath.VariableStack)4 XPathContext (org.apache.xpath.XPathContext)4 NodeVector (org.apache.xml.utils.NodeVector)3 XObject (org.apache.xpath.objects.XObject)3 IOException (java.io.IOException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 TransformerException (javax.xml.transform.TransformerException)2 ElemTemplateElement (org.apache.xalan.templates.ElemTemplateElement)2 Stylesheet (org.apache.xalan.templates.Stylesheet)2 StylesheetComposed (org.apache.xalan.templates.StylesheetComposed)2 XUnresolvedVariable (org.apache.xalan.templates.XUnresolvedVariable)2 DTM (org.apache.xml.dtm.DTM)2 DTMIterator (org.apache.xml.dtm.DTMIterator)2 SAXSourceLocator (org.apache.xml.utils.SAXSourceLocator)2 SAXException (org.xml.sax.SAXException)2 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)2 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)2