/// <summary> /// Set the value of a variable /// </summary> /// <param name="name">The name of the variable. This must match the name of a variable /// that was declared to the XPathCompiler. No error occurs if the expression does not /// actually reference a variable with this name.</param> /// <param name="value">The value to be given to the variable.</param> public void SetVariable(QName name, XdmValue value) { JXPathVariable var = null; String uri = (name.Uri == null ? "" : name.Uri); String local = name.LocalName; foreach (JXPathVariable v in declaredVariables) { String vuri = v.getVariableQName().getURI(); if (vuri == null) { vuri = ""; } if (vuri == uri && v.getVariableQName().getLocalPart() == local) { var = v; break; } } if (var == null) { // TODO: this seems to conflict with the documentation of the method throw new ArgumentException("Variable has not been declared: " + name); } dynamicContext.setVariable(var, value.Unwrap()); }
/// <summary> /// Set the value of a variable /// <param name="name">The name of the variable. This must match the name of a variable /// that was declared to the XPathCompiler. No error occurs if the expression does not /// actually reference a variable with this name.</param> /// <param name="value">The value to be given to the variable.</param> /// </summary> public void SetVariable(QName name, XdmValue value) { JXPathVariable var = null; String uri = (name.Uri == null ? "" : name.Uri); String local = name.LocalName; foreach (JXPathVariable v in declaredVariables) { String vuri = v.getVariableQName().getNamespaceURI(); if (vuri == null) { vuri = ""; } if (vuri == uri && v.getVariableQName().getLocalName() == local) { var = v; break; } } if (var == null) { throw new ArgumentException("Variable has not been declared: " + name); } dynamicContext.setVariable(var, value.Unwrap()); }