public override XPathSequence Evaluate(XPathSequence iter) { XPathSequence res = Args [0].Evaluate(iter); if (res.MoveNext()) { return(new XPathEmptySequence(iter.Context)); } XPathNavigator nav = res.Current as XPathNavigator; if (nav == null) { return(new XPathEmptySequence(iter.Context)); } nav = nav.Clone(); nav.MoveToRoot(); return(new SingleItemIterator(new XPathAtomicValue(nav.BaseURI, null), iter)); }
public override XPathSequence Evaluate(XPathSequence iter) { XPathItem item = null; if (Args.Length == 0) { item = iter.Context.CurrentItem; } else { XPathSequence res = Args [0].Evaluate(iter); if (!res.MoveNext()) { return(new XPathEmptySequence(iter.Context)); } item = res.Current; } return(new SingleItemIterator(new XPathAtomicValue(Core(item), null), iter)); }
public override XPathSequence Evaluate(XPathSequence iter) { XPathSequence res = Args [0].Evaluate(iter); if (res.MoveNext()) { return(new XPathEmptySequence(iter.Context)); } XPathNavigator nav = res.Current as XPathNavigator; if (nav == null) { return(new XPathEmptySequence(iter.Context)); } else { return(new SingleItemIterator(new XPathAtomicValue(nav.BaseURI, XmlSchemaSimpleType.XsString), iter)); } }
internal bool CanConvert(XPathSequence iter) { bool occured = false; bool onlyOnce = (occurence == Occurence.One || occurence == Occurence.Optional); bool required = (occurence == Occurence.One || occurence == Occurence.OneOrMore); foreach (XPathItem item in iter) { if (occured && onlyOnce) { return(false); } if (!CanConvert(item)) { return(false); } } return(occured || !required); }
private static XPathItem ToItem(object arg) { if (arg == null) { return(null); } XPathItem item = arg as XPathItem; if (item != null) { return(item); } XPathSequence seq = arg as XPathSequence; if (seq != null) { return(seq.MoveNext() ? seq.Current : null); } return(new XPathAtomicValue(arg, XmlTypeFromCliType(arg.GetType()))); }
public static bool FnDeepEqualImpl(XPathSequence p1, XPathSequence p2, CultureInfo collation) { // FIXME: use collation while (p1.MoveNext()) { if (!p2.MoveNext()) { return(false); } if (!FnDeepEqualItem(p1.Current, p2.Current, collation)) { return(false); } } if (p2.MoveNext()) { return(false); } return(true); }
public override XPathSequence Evaluate(XPathSequence iter) { // error name XPathSequence errorNameIter = Args.Length > 0 ? Args [0].Evaluate(iter) : null; XmlQualifiedName errorType = XmlQualifiedName.Empty; if (errorNameIter != null && errorNameIter.MoveNext()) { errorType = XQueryConvert.ItemToQName(errorNameIter.Current); } // description string description = Args.Length > 1 ? Args [1].EvaluateAsString(iter) : String.Empty; // error-object XPathSequence errorObjIter = Args.Length > 2 ? Args [2].Evaluate(iter) : null; // FIXME: add error-object information throw new XmlQueryException(errorType + description); }
public override XPathSequence Evaluate(XPathSequence iter) { XPathSequence res = Args [0].Evaluate(iter); if (!res.MoveNext()) { return(new XPathEmptySequence(iter.Context)); } XPathNavigator nav = res.Current as XPathNavigator; IXmlSchemaInfo info = nav.NodeType == XPathNodeType.Element ? nav.SchemaInfo : null; if (info != null) { return(new SingleItemIterator(new XPathAtomicValue(info.IsNil, null), iter)); } else { return(new XPathEmptySequence(iter.Context)); } }
private XmlQualifiedName EvaluateName(XPathSequence iter) { XmlQualifiedName name = Name; if (NameExpr != null) { XPathAtomicValue value = Atomize(new ExprSequenceIterator(iter, NameExpr)); IXmlNamespaceResolver res = GetNSResolver(iter); switch (value.XmlType.TypeCode) { case XmlTypeCode.QName: name = (XmlQualifiedName)value.ValueAs(typeof(XmlQualifiedName), res); break; case XmlTypeCode.String: try { // nonprefixed attribute name == element's local namespace if (value.Value.IndexOf(':') < 0) { name = new XmlQualifiedName(value.Value); } else { name = InternalPool.ParseQName(value.Value, res); } } catch (ArgumentException ex) { // FIXME: add more info throw new XmlQueryException(String.Format("The evaluation result of the name expression could not be resolved as a valid QName. Evaluation result string is '{0}'.", value.Value)); } break; default: // FIXME: add more info throw new XmlQueryException("A name of an attribute constructor must be resolved to either a QName or string."); } } return(name); }
public static object FnTrace(XQueryContext ctx, object value, string label) { if (value == null) { return(new XPathEmptySequence(ctx)); } XPathSequence seq = value as XPathSequence; if (seq == null) { XPathAtomicValue av = value as XPathAtomicValue; if (av == null) { av = new XPathAtomicValue(value, InternalPool.GetBuiltInType( InternalPool.XmlTypeCodeFromRuntimeType( value.GetType(), true))); } seq = new SingleItemIterator(av, ctx); } return(new TracingIterator(seq, label)); }
internal XQueryContextManager(XQueryStaticContext ctx, XPathItem input, XmlWriter writer, XmlResolver resolver, XmlArgumentList args) { this.input = input; this.staticContext = ctx; this.args = args; currentWriter = writer; this.extDocResolver = resolver; namespaceManager = new XmlNamespaceManager(ctx.NameTable); foreach (DictionaryEntry de in ctx.NSResolver.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml)) { namespaceManager.AddNamespace(de.Key.ToString(), de.Value.ToString()); } namespaceManager.PushScope(); currentContext = new XQueryContext(this, null, new Hashtable()); if (input != null) { currentSequence = new SingleItemIterator(input, currentContext); currentSequence.MoveNext(); } currentContext = new XQueryContext(this, currentSequence, new Hashtable()); }
public override void Serialize(XPathSequence iter) { iter.Context.Writer.WriteComment(Atomize(new ExprSequenceIterator(iter, Content)).Value); }
public override void Serialize(XPathSequence iter) { iter.Context.Writer.WriteProcessingInstruction( GetName(iter), Atomize(new ExprSequenceIterator(iter, Content)).Value); }
public override XPathSequence Evaluate(XPathSequence iter) { // TBD throw new NotImplementedException(); }
public override XPathSequence Evaluate(XPathSequence iter) { return(EvaluateNode(iter, XPathNodeType.Root)); }
public override object Invoke(XPathSequence current, object [] args) { throw new SystemException("XQuery internal error: should not happen."); }
public override void Serialize(XPathSequence iter) { // TBD throw new NotImplementedException(); }
public override XPathSequence Evaluate(XPathSequence iter) { return(new TracingIterator(Args [0].Evaluate(iter), Args [1].EvaluateAsString(iter))); }
internal bool Matches(XPathSequence iter) { throw new NotImplementedException(); }
public static object FnDeepEqual(XQueryContext ctx, XPathSequence p1, XPathSequence p2) { return(FnDeepEqualImpl(p1, p2, ctx.DefaultCollation)); }
// Basically it should be optimized by XQueryASTCompiler public static XPathSequence FnUnordered(XPathSequence e) { return(e); }
public static object FnDeepEqual(XQueryContext ctx, XPathSequence p1, XPathSequence p2, string collation) { return(FnDeepEqualImpl(p1, p2, ctx.GetCulture(collation))); }
private static TimeSpan FnAvgYearMonthDuration(XPathSequence e) { throw new NotImplementedException(); }
private static TimeSpan FnAvgDecimal(XPathSequence e) { throw new NotImplementedException(); }
public override XPathSequence Evaluate(XPathSequence iter) { return(EvaluateNode(iter)); }
public override XPathSequence Evaluate(XPathSequence iter) { return(new SingleItemIterator(XQueryConvert.ItemToItem(Atomize(Args [0].Evaluate(iter)), null), iter)); }
public XPathSequence EvaluateNode(XPathSequence iter) { return(EvaluateNode(iter, XPathNodeType.All)); }
public static object FnSubsequence(XPathSequence sourceSeq, double startingLoc, double length) { throw new NotImplementedException(); }
public override XPathSequence Evaluate(XPathSequence iter) { return(new AtomizingIterator(Args [0].Evaluate(iter))); }
public abstract object Invoke(XPathSequence current, object [] args);