Beispiel #1
0
 public PathStep(object nodeTest, XPath2ExprType type)
 {
     this.nodeTest = nodeTest;
     this.type     = type;
     this.node     = null;
 }
Beispiel #2
0
        private IEnumerable <XPathItem> CreateEnumerator(object[] dataPool, AbstractNode expr,
                                                         XPath2NodeIterator baseIter)
        {
            XPath2NodeIterator iter    = baseIter.Clone();
            ValueNode          numexpr = expr as ValueNode;

            if (numexpr != null && numexpr.Content is Integer)
            {
                Integer pos = (Integer)numexpr.Content;
                foreach (XPathItem item in iter)
                {
                    if (pos == 1)
                    {
                        yield return(item);

                        break;
                    }
                    else
                    {
                        pos--;
                    }
                }
            }
            else
            {
                ContextProvider provider = new ContextProvider(iter);
                object          res      = Undefined.Value;
                while (iter.MoveNext())
                {
                    if (m_contextSensitive || res == Undefined.Value)
                    {
                        res = expr.Execute(provider, dataPool);
                    }
                    if (res == Undefined.Value)
                    {
                        if (!m_contextSensitive)
                        {
                            break;
                        }
                        continue;
                    }
                    XPath2NodeIterator iter2 = res as XPath2NodeIterator;
                    XPathItem          item;
                    if (iter2 != null)
                    {
                        iter2 = iter2.Clone();
                        if (!iter2.MoveNext())
                        {
                            continue;
                        }
                        item = iter2.Current.Clone();
                        if (!item.IsNode && iter2.MoveNext())
                        {
                            throw new XPath2Exception("FORG0006", Resources.FORG0006, "fn:boolean()",
                                                      new SequenceType(XmlTypeCode.AnyAtomicType, XmlTypeCardinality.OneOrMore));
                        }
                    }
                    else
                    {
                        item = res as XPathItem;
                        if (item == null)
                        {
                            item = new XPath2Item(res);
                        }
                    }
                    if (item.IsNode)
                    {
                        yield return(iter.Current);
                    }
                    else
                    {
                        if (ValueProxy.IsNumeric(item.ValueType))
                        {
                            if (CoreFuncs.OperatorEq(iter.CurrentPosition + 1, item.GetTypedValue()) == CoreFuncs.True)
                            {
                                yield return(iter.Current);

                                if (!m_contextSensitive)
                                {
                                    break;
                                }
                            }
                        }
                        else if (CoreFuncs.GetBooleanValue(item))
                        {
                            yield return(iter.Current);
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public PathStep(AbstractNode node)
 {
     this.nodeTest = null;
     this.type     = XPath2ExprType.Expr;
     this.node     = node;
 }
Beispiel #4
0
 public ExprNode(XPath2Context context, AbstractNode node)
     : base(context)
 {
     Add(node);
 }