public XObject getVariableOrParam(XPathContext xctxt, QName qname) throws TransformerException,IllegalArgumentException { if ( qname == null ) { //JAXP 1.3 spec says that if variable name is null then // we need to through IllegalArgumentException String fmsg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_ARG_CANNOT_BE_NULL, new Object[] {"Variable qname"} ); throw new IllegalArgumentException( fmsg ); } javax.xml.namespace.QName name = new javax.xml.namespace.QName( qname.getNamespace(), qname.getLocalPart()); Object varValue = resolver.resolveVariable( name ); if ( varValue == null ) { String fmsg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_RESOLVE_VARIABLE_RETURNS_NULL, new Object[] { name.toString()} ); throw new TransformerException( fmsg ); } return XObject.create( varValue, xctxt ); }
/** * Tell if this is a psuedo variable reference, declared by Xalan instead * of by the user. */ public boolean isPsuedoVar() { java.lang.String ns = m_qname.getNamespaceURI(); if((null != ns) && ns.equals(RedundentExprEliminator.PSUEDOVARNAMESPACE)) { if(m_qname.getLocalName().startsWith("#")) return true; } return false; }
/** * Construct a dummy parameter argument, with no QName and no * value (either expression string or value XObject). isVisible * defaults to true. */ public Arg() { m_qname = new QName(""); ; // so that string compares can be done. m_val = null; m_expression = null; m_isVisible = true; m_isFromWithParam = false; }
/** * Given a qualified name, return an integer ID that can be * quickly compared. * * @param qname a qualified name object, must not be null. * * @return the expanded-name id of the qualified name. */ public int getQNameID(QName qname) { return m_ent.getExpandedTypeID(qname.getNamespace(), qname.getLocalName(), // The type doesn't matter for our // purposes. org.apache.xml.dtm.DTM.ELEMENT_NODE); }
String s = props.getProperty(key); Vector v = new Vector(); int l = s.length(); boolean inCurly = false; QName qname = QName.getQNameFromString(buf.toString()); v.addElement(qname); buf.reset(); QName qname = QName.getQNameFromString(buf.toString()); v.addElement(qname); buf.reset();
/** * Searches for the qname property with the specified key in the property list. * If the key is not found in this property list, the default property list, * and its defaults, recursively, are then checked. The method returns * <code>null</code> if the property is not found. * * @param key the property key. * @param props the list of properties to search in. * @return the value in this property list as a QName value, or false * if null or not "yes". */ public static QName getQNameProperty(String key, Properties props) { String s = props.getProperty(key); if (null != s) return QName.getQNameFromString(s); else return null; }
/** * Searches for the property with the specified key in the property list. * If the key is not found in this property list, the default property list, * and its defaults, recursively, are then checked. The method returns * <code>null</code> if the property is not found. * * @param key the property key. * @return the value in this property list with the specified key value. */ public String getProperty(QName key) { return m_properties.getProperty(key.toNamespacedString()); }
/** * Set an output property with a QName list value. The QNames will be turned * into strings with the namespace in curly brackets. * * @param key the key to be placed into the property list. * @param v non-null list of QNames corresponding to <tt>key</tt>. * @see javax.xml.transform.OutputKeys */ public void setQNameProperties(String key, Vector v) { int s = v.size(); // Just an initial guess at reasonable tuning parameters FastStringBuffer fsb = new FastStringBuffer(9,9); for (int i = 0; i < s; i++) { QName qname = (QName) v.elementAt(i); fsb.append(qname.toNamespacedString()); // Don't append space after last value if (i < s-1) fsb.append(' '); } m_properties.put(key, fsb.toString()); }
/** * @return key declarations for the key associated to this KeyTable */ private Vector getKeyDeclarations() { int nDeclarations = m_keyDeclarations.size(); Vector keyDecls = new Vector(nDeclarations); // Walk through each of the declarations made with xsl:key for (int i = 0; i < nDeclarations; i++) { KeyDeclaration kd = (KeyDeclaration) m_keyDeclarations.elementAt(i); // Add the declaration if the name on this key declaration // matches the name on the iterator for this walker. if (kd.getName().equals(getKeyTableName())) { keyDecls.add(kd); } } return keyDecls; }
/** * Set an output property. * * @param key the key to be placed into the property list. * @param value the value corresponding to <tt>key</tt>. * @see javax.xml.transform.OutputKeys */ public void setBooleanProperty(QName key, boolean value) { m_properties.put(key.toNamespacedString(), value ? "yes" : "no"); }
/** * NEEDSDOC Method replaceOrPushUserParam * * * NEEDSDOC @param qname * NEEDSDOC @param xval */ private void replaceOrPushUserParam(QName qname, XObject xval) { int n = m_userParams.size(); for (int i = n - 1; i >= 0; i--) { Arg arg = (Arg) m_userParams.elementAt(i); if (arg.getQName().equals(qname)) { m_userParams.setElementAt(new Arg(qname, xval, true), i); return; } } m_userParams.addElement(new Arg(qname, xval, true)); }
/** * 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); } } }
int sz = vars.size(); for (int i = vars.size()-1; i >= 0; i--) QName qn = (QName)vars.elementAt(i); if(qn.equals(m_qname)) java.lang.String msg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_COULD_NOT_FIND_VAR, new Object[]{m_qname.toString()}); TransformerException te = new TransformerException(msg, this);
return; int n = m_userParams.size(); for (int i = n - 1; i >= 0; i--) Arg arg = (Arg) m_userParams.elementAt(i); QName name = arg.getQName(); String s1 = name.getNamespace(); String s2 = name.getLocalPart(); setParameter(s2, s1, arg.getVal().object());
QName qname = QName.getQNameFromString(name); int n = m_userParams.size(); Arg arg = (Arg) m_userParams.elementAt(i); if (arg.getQName().equals(qname)) return arg.getVal().object();
/** * Get an "xsl:variable" property. * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a> * * @param qname Qualified name of variable or param * * @return The ElemVariable with the given qualified name */ public ElemVariable getVariableOrParamComposed(QName qname) { if (null != m_variables) { int n = m_variables.size(); for (int i = 0; i < n; i++) { ElemVariable var = (ElemVariable)m_variables.elementAt(i); if(var.getName().equals(qname)) return var; } } return null; }
throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_SET_PARAM_VALUE, new Object[]{name})); m_userParams = new Vector(); replaceOrPushUserParam(new QName(s1), XObject.create(value, getXPathContext())); setParameter(s1, null, value); replaceOrPushUserParam(new QName(s1, s2), XObject.create(value, getXPathContext())); setParameter(s2, s1, value);
int nDeclarations = keys.size(); KeyDeclaration kd = (KeyDeclaration) keys.elementAt(i); if (!kd.getName().equals(name)) continue; if (xuse.getType() != xuse.CLASS_NODESET) XMLString exprResult = xuse.xstr(); XSLMessages.createMessage( XSLTErrorResources.ER_NO_XSLKEY_DECLARATION, new Object[] { name.getLocalName()})); return DTMIterator.FILTER_REJECT;
xctxt.getNamespaceContext(); if (vvar.getName().equals(qname)) return getLocalVariable(xctxt, vvar.getIndex()); throw new javax.xml.transform.TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VAR_NOT_RESOLVABLE, new Object[]{qname.toString()})); //"Variable not resolvable: " + qname);