Search in sources :

Example 46 with QName

use of org.apache.xml.utils.QName in project robovm by robovm.

the class TransformerImpl method setParameter.

/**
   * Set a parameter for the transformation.
   *
   * @param name The name of the parameter,
   *             which may have a namespace URI.
   * @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, Object value) {
    if (value == null) {
        throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_SET_PARAM_VALUE, new Object[] { name }));
    }
    StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
    try {
        // The first string might be the namespace, or it might be 
        // the local name, if the namespace is null.
        String s1 = tokenizer.nextToken();
        String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
        if (null == m_userParams)
            m_userParams = new Vector();
        if (null == s2) {
            replaceOrPushUserParam(new QName(s1), XObject.create(value, getXPathContext()));
            setParameter(s1, null, value);
        } else {
            replaceOrPushUserParam(new QName(s1, s2), XObject.create(value, getXPathContext()));
            setParameter(s2, s1, value);
        }
    } catch (java.util.NoSuchElementException nsee) {
    // Should throw some sort of an error.
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) QName(org.apache.xml.utils.QName) XObject(org.apache.xpath.objects.XObject) Vector(java.util.Vector) NodeVector(org.apache.xml.utils.NodeVector)

Aggregations

QName (org.apache.xml.utils.QName)46 TransformerException (javax.xml.transform.TransformerException)16 Vector (java.util.Vector)12 XObject (org.apache.xpath.objects.XObject)10 StringTokenizer (java.util.StringTokenizer)6 DTM (org.apache.xml.dtm.DTM)6 DTMIterator (org.apache.xml.dtm.DTMIterator)6 Expression (org.apache.xpath.Expression)6 XPathContext (org.apache.xpath.XPathContext)6 TransformerImpl (org.apache.xalan.transformer.TransformerImpl)4 FastStringBuffer (org.apache.xml.utils.FastStringBuffer)4 StringVector (org.apache.xml.utils.StringVector)4 Arg (org.apache.xpath.Arg)4 ExpressionOwner (org.apache.xpath.ExpressionOwner)4 LocPathIterator (org.apache.xpath.axes.LocPathIterator)4 XString (org.apache.xpath.objects.XString)4 SAXException (org.xml.sax.SAXException)4 Hashtable (java.util.Hashtable)2 AVT (org.apache.xalan.templates.AVT)2 KeyDeclaration (org.apache.xalan.templates.KeyDeclaration)2