Exemple #1
0
		public override object Evaluate (BaseIterator iter)
		{
			IXsltContextVariable var = null;
			
			XsltContext context = iter.NamespaceManager as XsltContext;
			if (context != null) {
				if (resolvedName)
					var = context.ResolveVariable (_name);
				else
					var = context.ResolveVariable (new XmlQualifiedName (_name.Name, _name.Namespace));
			}
			else
				throw new XPathException (String.Format ("XSLT context is required to resolve variable. Current namespace manager in current node-set '{0}' is '{1}'", iter.GetType (), iter.NamespaceManager != null ? iter.NamespaceManager.GetType () : null));
			
			if (var == null)
				throw new XPathException ("variable "+_name.ToString ()+" not found");
			object objResult = var.Evaluate (context);
			XPathNodeIterator iterResult = objResult as XPathNodeIterator;
			if (iterResult != null)
				return iterResult is BaseIterator ? iterResult : new WrapperIterator (iterResult, iter.NamespaceManager);
			return objResult;
		}
Exemple #2
0
 public override string ToString()
 {
     return(_iter.GetType().FullName);
 }
        public override object Evaluate(BaseIterator iter)
        {
            XsltContext xsltContext = iter.NamespaceManager as XsltContext;

            if (xsltContext == null)
            {
                throw new XPathException(string.Format("XSLT context is required to resolve variable. Current namespace manager in current node-set '{0}' is '{1}'", iter.GetType(), (iter.NamespaceManager == null) ? null : iter.NamespaceManager.GetType()));
            }
            IXsltContextVariable xsltContextVariable;

            if (this.resolvedName)
            {
                xsltContextVariable = xsltContext.ResolveVariable(this._name);
            }
            else
            {
                xsltContextVariable = xsltContext.ResolveVariable(new XmlQualifiedName(this._name.Name, this._name.Namespace));
            }
            if (xsltContextVariable == null)
            {
                throw new XPathException("variable " + this._name.ToString() + " not found");
            }
            object            obj = xsltContextVariable.Evaluate(xsltContext);
            XPathNodeIterator xpathNodeIterator = obj as XPathNodeIterator;

            if (xpathNodeIterator != null)
            {
                return((!(xpathNodeIterator is BaseIterator)) ? new WrapperIterator(xpathNodeIterator, iter.NamespaceManager) : xpathNodeIterator);
            }
            return(obj);
        }