public static object FnOneOrMore (XPathSequence e) { if (!e.Clone ().MoveNext ()) throw new XmlQueryException ("one-or-more() function detected that the argument sequence contains no items."); return e; }
public override XPathSequence Evaluate (XPathSequence iter) { XQueryContext ctx = iter.Context; if (iter.Position == 0) { iter = iter.Clone (); if (!iter.MoveNext ()) return new XPathEmptySequence (iter.Context); } XPathNavigator nav = iter.Current as XPathNavigator; if (nav == null) throw new XmlQueryException ("Node set is expected."); NodeIterator argIter = null; switch (Axis.AxisType) { case XPathAxisType.Child: argIter = new ChildIterator (nav, ctx); break; case XPathAxisType.Descendant: argIter = new DescendantIterator (nav, ctx); break; case XPathAxisType.Attribute: argIter = new AttributeIterator (nav, ctx); break; case XPathAxisType.Self: argIter = new SelfIterator (nav, ctx); break; case XPathAxisType.DescendantOrSelf: argIter = new DescendantOrSelfIterator (nav, ctx); break; case XPathAxisType.FollowingSibling: argIter = new FollowingSiblingIterator (nav, ctx); break; case XPathAxisType.Following: argIter = new FollowingIterator (nav, ctx); break; case XPathAxisType.Parent: argIter = new ParentIterator (nav, ctx); break; case XPathAxisType.Ancestor: argIter = new AncestorIterator (nav, ctx); break; case XPathAxisType.PrecedingSibling: argIter = new PrecedingSiblingIterator (nav, ctx); break; case XPathAxisType.Preceding: argIter = new PrecedingIterator (nav, ctx); break; case XPathAxisType.AncestorOrSelf: argIter = new AncestorOrSelfIterator (nav, ctx); break; case XPathAxisType.Namespace: // only applicable under XPath 2.0: not XQuery 1.0 argIter = new NamespaceIterator (nav, ctx); break; } return new AxisIterator (argIter, this); }