Example #1
0
        // Invoked from XsltKey (XPathFunction)
        public BaseIterator Evaluate(BaseIterator iter,
                                     Expression valueExpr)
        {
            XPathNodeIterator i = iter;

            if (iter.CurrentPosition == 0)
            {
                i = iter.Clone();
                i.MoveNext();
            }
            XPathNavigator nav = i.Current;

            object            o   = valueExpr.Evaluate(iter);
            XPathNodeIterator it  = o as XPathNodeIterator;
            XsltContext       ctx = iter.NamespaceManager as XsltContext;

            BaseIterator result = null;

            if (it != null)
            {
                while (it.MoveNext())
                {
                    ArrayList nodes = GetNodesByValue(
                        nav, it.Current.Value, ctx);
                    if (nodes == null)
                    {
                        continue;
                    }
                    ListIterator tmp =
                        new ListIterator(nodes, ctx);
                    if (result == null)
                    {
                        result = tmp;
                    }
                    else
                    {
                        result = new UnionIterator(
                            iter, result, tmp);
                    }
                }
            }
            else
            {
                ArrayList nodes = GetNodesByValue(
                    nav, XPathFunctions.ToString(o), ctx);
                if (nodes != null)
                {
                    result = new ListIterator(nodes, ctx);
                }
            }

            return(result != null ? result : new NullIterator(iter));
        }
Example #2
0
        public BaseIterator Evaluate(BaseIterator iter, Expression valueExpr)
        {
            XPathNodeIterator xpathNodeIterator = iter;

            if (iter.CurrentPosition == 0)
            {
                xpathNodeIterator = iter.Clone();
                xpathNodeIterator.MoveNext();
            }
            XPathNavigator    xpathNavigator     = xpathNodeIterator.Current;
            object            obj                = valueExpr.Evaluate(iter);
            XPathNodeIterator xpathNodeIterator2 = obj as XPathNodeIterator;
            XsltContext       nsm                = iter.NamespaceManager as XsltContext;
            BaseIterator      baseIterator       = null;

            if (xpathNodeIterator2 != null)
            {
                while (xpathNodeIterator2.MoveNext())
                {
                    XPathNavigator xpathNavigator2 = xpathNodeIterator2.Current;
                    ArrayList      nodesByValue    = this.GetNodesByValue(xpathNavigator, xpathNavigator2.Value, nsm);
                    if (nodesByValue != null)
                    {
                        ListIterator listIterator = new ListIterator(nodesByValue, nsm);
                        if (baseIterator == null)
                        {
                            baseIterator = listIterator;
                        }
                        else
                        {
                            baseIterator = new UnionIterator(iter, baseIterator, listIterator);
                        }
                    }
                }
            }
            else if (xpathNavigator != null)
            {
                ArrayList nodesByValue2 = this.GetNodesByValue(xpathNavigator, XPathFunctions.ToString(obj), nsm);
                if (nodesByValue2 != null)
                {
                    baseIterator = new ListIterator(nodesByValue2, nsm);
                }
            }
            return((baseIterator == null) ? new NullIterator(iter) : baseIterator);
        }