public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            object            o   = p.Evaluate(select);
            XPathNodeIterator itr = o as XPathNodeIterator;

            if (itr != null)
            {
                while (itr.MoveNext())
                {
                    CopyNode(p, itr.Current);
                }
            }
            else
            {
                XPathNavigator nav = o as XPathNavigator; // RTF
                if (nav != null)
                {
                    CopyNode(p, nav);
                }
                else
                {
                    p.Out.WriteString(XPathFunctions.ToString(o));
                }
            }
        }
Ejemplo n.º 2
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, base.DebugInput);
            }
            object            obj = p.Evaluate(this.select);
            XPathNodeIterator xpathNodeIterator = obj as XPathNodeIterator;

            if (xpathNodeIterator != null)
            {
                while (xpathNodeIterator.MoveNext())
                {
                    XPathNavigator nav = xpathNodeIterator.Current;
                    this.CopyNode(p, nav);
                }
            }
            else
            {
                XPathNavigator xpathNavigator = obj as XPathNavigator;
                if (xpathNavigator != null)
                {
                    this.CopyNode(p, xpathNavigator);
                }
                else
                {
                    p.Out.WriteString(XPathFunctions.ToString(obj));
                }
            }
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        private void CollectIndex(XPathNavigator nav, XPathNavigator target, Hashtable map, XslKey key)
        {
            switch (key.Use.ReturnType)
            {
            case XPathResultType.NodeSet:
            {
                XPathNodeIterator xpathNodeIterator = nav.Select(key.Use);
                while (xpathNodeIterator.MoveNext())
                {
                    XPathNavigator xpathNavigator = xpathNodeIterator.Current;
                    this.AddIndex(xpathNavigator.Value, target, map);
                }
                return;
            }

            case XPathResultType.Any:
            {
                object            obj = nav.Evaluate(key.Use);
                XPathNodeIterator xpathNodeIterator = obj as XPathNodeIterator;
                if (xpathNodeIterator != null)
                {
                    while (xpathNodeIterator.MoveNext())
                    {
                        XPathNavigator xpathNavigator2 = xpathNodeIterator.Current;
                        this.AddIndex(xpathNavigator2.Value, target, map);
                    }
                }
                else
                {
                    this.AddIndex(XPathFunctions.ToString(obj), target, map);
                }
                return;
            }
            }
            string key2 = nav.EvaluateString(key.Use, null, null);

            this.AddIndex(key2, target, map);
        }
Ejemplo n.º 6
0
        private void CollectIndex(XPathNavigator nav, XPathNavigator target, Hashtable map, XslKey key)
        {
            XPathNodeIterator iter;

            switch (key.Use.ReturnType)
            {
            case XPathResultType.NodeSet:
                iter = nav.Select(key.Use);
                while (iter.MoveNext())
                {
                    AddIndex(iter.Current.Value, target, map);
                }
                break;

            case XPathResultType.Any:
                object o = nav.Evaluate(key.Use);
                iter = o as XPathNodeIterator;
                if (iter != null)
                {
                    while (iter.MoveNext())
                    {
                        AddIndex(iter.Current.Value, target, map);
                    }
                }
                else
                {
                    AddIndex(XPathFunctions.ToString(o), target, map);
                }
                break;

            default:
                string keyValue = nav.EvaluateString(key.Use, null, null);
                AddIndex(keyValue, target, map);
                break;
            }
        }