XQueryFunctionCliImpl.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. //
  2. // XQueryFunctionCliImple.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. //
  8. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. //
  30. // Runtime-level (native) implementation of XQuery 1.0 and XPath 2.0
  31. // Functions implementation. XQueryCliFunction
  32. // See XQuery 1.0 and XPath 2.0 Functions and Operators.
  33. //
  34. #if NET_2_0
  35. using System;
  36. using System.Collections;
  37. using System.Globalization;
  38. using System.Text.RegularExpressions;
  39. using System.Xml;
  40. using System.Xml.Query;
  41. using System.Xml.Schema;
  42. using System.Xml.XPath;
  43. namespace Mono.Xml.XPath2
  44. {
  45. public class XQueryFunctionCliImpl
  46. {
  47. internal static XmlSchemaType XmlTypeFromCliType (Type cliType)
  48. {
  49. switch (Type.GetTypeCode (cliType)) {
  50. case TypeCode.Int32:
  51. return XmlSchemaSimpleType.XsInt;
  52. case TypeCode.Decimal:
  53. return XmlSchemaSimpleType.XsDecimal;
  54. case TypeCode.Double:
  55. return XmlSchemaSimpleType.XsDouble;
  56. case TypeCode.Single:
  57. return XmlSchemaSimpleType.XsFloat;
  58. case TypeCode.Int64:
  59. return XmlSchemaSimpleType.XsLong;
  60. case TypeCode.Int16:
  61. return XmlSchemaSimpleType.XsShort;
  62. case TypeCode.UInt16:
  63. return XmlSchemaSimpleType.XsUnsignedShort;
  64. case TypeCode.UInt32:
  65. return XmlSchemaSimpleType.XsUnsignedInt;
  66. case TypeCode.String:
  67. return XmlSchemaSimpleType.XsString;
  68. case TypeCode.DateTime:
  69. return XmlSchemaSimpleType.XsDateTime;
  70. case TypeCode.Boolean:
  71. return XmlSchemaSimpleType.XsBoolean;
  72. }
  73. if (cliType == typeof (XmlQualifiedName))
  74. return XmlSchemaSimpleType.XsQName;
  75. return null;
  76. }
  77. private static XPathItem ToItem (object arg)
  78. {
  79. if (arg == null)
  80. return null;
  81. XPathItem item = arg as XPathItem;
  82. if (item != null)
  83. return item;
  84. XPathSequence seq = arg as XPathSequence;
  85. if (seq != null)
  86. return seq.MoveNext () ? seq.Current : null;
  87. return new XPathAtomicValue (arg, XmlTypeFromCliType (arg.GetType ()));
  88. }
  89. // Accessors
  90. public static XmlQualifiedName FnNodeName (XPathNavigator arg)
  91. {
  92. if (arg == null)
  93. return XmlQualifiedName.Empty;
  94. return arg.LocalName == String.Empty ?
  95. XmlQualifiedName.Empty :
  96. new XmlQualifiedName (arg.LocalName, arg.NamespaceURI);
  97. }
  98. public static bool FnNilled (XPathNavigator arg)
  99. {
  100. if (arg == null)
  101. return false;
  102. IXmlSchemaInfo info = arg.NodeType == XPathNodeType.Element ? arg.SchemaInfo : null;
  103. return info != null && info.IsNil;
  104. }
  105. public static string FnString (XQueryContext context)
  106. {
  107. XPathItem item = context.CurrentItem;
  108. if (item == null)
  109. throw new ArgumentException ("FONC0001: undefined context item");
  110. return FnString (item);
  111. }
  112. public static string FnString (object arg)
  113. {
  114. XPathNavigator nav = arg as XPathNavigator;
  115. if (nav != null)
  116. return nav.Value;
  117. XPathItem item = ToItem (arg);
  118. return item != null ? XQueryConvert.ItemToString (item) : null;
  119. }
  120. public static XPathAtomicValue FnData (object arg)
  121. {
  122. XPathNavigator nav = arg as XPathNavigator;
  123. if (nav != null) {
  124. XmlSchemaType st = nav.SchemaInfo != null ? nav.SchemaInfo.SchemaType : null;
  125. return new XPathAtomicValue (nav.TypedValue, st != null ? st : XmlSchemaComplexType.AnyType);
  126. }
  127. else
  128. return (XPathAtomicValue) arg;
  129. }
  130. public static string FnBaseUri (XPathNavigator nav)
  131. {
  132. return nav != null ? nav.BaseURI : null;
  133. }
  134. public static string FnDocumentUri (XPathNavigator nav)
  135. {
  136. if (nav == null)
  137. return null;
  138. XPathNavigator root = nav.Clone ();
  139. root.MoveToRoot ();
  140. return root.BaseURI;
  141. }
  142. // Error
  143. [MonoTODO]
  144. public static void FnError (object arg)
  145. {
  146. throw new NotImplementedException ();
  147. }
  148. // Trace
  149. [MonoTODO]
  150. public static object FnTrace (object arg)
  151. {
  152. throw new NotImplementedException ();
  153. }
  154. // Numeric Operation
  155. [MonoTODO]
  156. public static object FnAbs (ValueType arg)
  157. {
  158. throw new NotImplementedException ();
  159. }
  160. [MonoTODO]
  161. public static object FnCeiling (ValueType arg)
  162. {
  163. throw new NotImplementedException ();
  164. }
  165. [MonoTODO]
  166. public static object FnFloor (ValueType arg)
  167. {
  168. throw new NotImplementedException ();
  169. }
  170. [MonoTODO]
  171. public static object FnRound (ValueType arg)
  172. {
  173. throw new NotImplementedException ();
  174. }
  175. [MonoTODO]
  176. public static object FnRoundHalfToEven (ValueType arg)
  177. {
  178. throw new NotImplementedException ();
  179. }
  180. [MonoTODO]
  181. public static string FnCodepointsToString (int [] arg)
  182. {
  183. throw new NotImplementedException ();
  184. }
  185. [MonoTODO]
  186. public static int [] FnStringToCodepoints (string arg)
  187. {
  188. throw new NotImplementedException ();
  189. }
  190. public static object FnCompare (string s1, string s2)
  191. {
  192. return string.Compare (s1, s2);
  193. }
  194. public static object FnCompare (string s1, string s2, string collation)
  195. {
  196. throw new NotImplementedException ();
  197. }
  198. public static object FnConcat (object o1, object o2)
  199. {
  200. return String.Concat (o1, o2);
  201. }
  202. public static object FnStringJoin (string [] strings, string separator)
  203. {
  204. return String.Join (separator, strings);
  205. }
  206. public static object FnSubstring (string src, double loc)
  207. {
  208. return src.Substring ((int) loc);
  209. }
  210. public static object FnSubstring (string src, double loc, double length)
  211. {
  212. return src.Substring ((int) loc, (int) length);
  213. }
  214. public static int FnStringLength (XQueryContext ctx)
  215. {
  216. return FnString (ctx).Length;
  217. }
  218. public static int FnStringLength (string s)
  219. {
  220. return s.Length;
  221. }
  222. public static object FnNormalizeSpace (XQueryContext ctx)
  223. {
  224. return FnNormalizeSpace (FnString (ctx));
  225. }
  226. [MonoTODO]
  227. public static object FnNormalizeSpace (string s)
  228. {
  229. throw new NotImplementedException ();
  230. }
  231. public static object FnNormalizeUnicode (string arg)
  232. {
  233. return FnNormalizeUnicode (arg, "NFC");
  234. }
  235. [MonoTODO]
  236. public static object FnNormalizeUnicode (string arg, string normalizationForm)
  237. {
  238. throw new NotImplementedException ();
  239. }
  240. public static object FnUpperCase (string arg)
  241. {
  242. // FIXME: supply culture
  243. return arg.ToUpper ();
  244. }
  245. public static object FnLowerCase (string arg)
  246. {
  247. // FIXME: supply culture
  248. return arg.ToLower ();
  249. }
  250. public static object FnTranslate (string arg, string mapString, string transString)
  251. {
  252. return arg == null ? null : arg.Replace (mapString, transString);
  253. }
  254. [MonoTODO]
  255. public static object FnEscapeUri (string uriPart, bool escapeReserved)
  256. {
  257. throw new NotImplementedException ();
  258. }
  259. public static object FnContains (XQueryContext ctx, string arg1, string arg2)
  260. {
  261. return FnContains (arg1, arg2, ctx.DefaultCollation);
  262. }
  263. public static object FnContains (XQueryContext ctx, string arg1, string arg2, string collation)
  264. {
  265. return FnContains (arg1, arg2, ctx.GetCulture (collation));
  266. }
  267. private static object FnContains (string arg1, string arg2, CultureInfo ci)
  268. {
  269. if (arg1 == null)
  270. arg1 = String.Empty;
  271. if (arg2 == null)
  272. arg2 = String.Empty;
  273. if (arg2 == String.Empty)
  274. return true;
  275. return ci.CompareInfo.IndexOf (arg1, arg2) >= 0;
  276. }
  277. public static bool FnStartsWith (XQueryContext ctx, string arg1, string arg2)
  278. {
  279. return FnStartsWith (arg1, arg2, ctx.DefaultCollation);
  280. }
  281. public static bool FnStartsWith (XQueryContext ctx, string arg1, string arg2, string collation)
  282. {
  283. return FnStartsWith (arg1, arg2, ctx.GetCulture (collation));
  284. }
  285. private static bool FnStartsWith (string arg1, string arg2, CultureInfo ci)
  286. {
  287. return ci.CompareInfo.IsPrefix (arg1, arg2);
  288. }
  289. public static bool FnEndsWith (XQueryContext ctx, string arg1, string arg2)
  290. {
  291. return FnEndsWith (arg1, arg2, ctx.DefaultCollation);
  292. }
  293. public static bool FnEndsWith (XQueryContext ctx, string arg1, string arg2, string collation)
  294. {
  295. return FnEndsWith (arg1, arg2, ctx.GetCulture (collation));
  296. }
  297. private static bool FnEndsWith (string arg1, string arg2, CultureInfo ci)
  298. {
  299. return ci.CompareInfo.IsSuffix (arg1, arg2);
  300. }
  301. public static string FnSubstringBefore (XQueryContext ctx, string arg1, string arg2)
  302. {
  303. return FnSubstringBefore (arg1, arg2, ctx.DefaultCollation);
  304. }
  305. public static string FnSubstringBefore (XQueryContext ctx, string arg1, string arg2, string collation)
  306. {
  307. return FnSubstringBefore (arg1, arg2, ctx.GetCulture (collation));
  308. }
  309. private static string FnSubstringBefore (string arg1, string arg2, CultureInfo ci)
  310. {
  311. int index = ci.CompareInfo.IndexOf (arg1, arg2);
  312. return arg1.Substring (0, index);
  313. }
  314. public static string FnSubstringAfter (XQueryContext ctx, string arg1, string arg2)
  315. {
  316. return FnSubstringAfter (arg1, arg2, ctx.DefaultCollation);
  317. }
  318. public static string FnSubstringAfter (XQueryContext ctx, string arg1, string arg2, string collation)
  319. {
  320. return FnSubstringAfter (arg1, arg2, ctx.GetCulture (collation));
  321. }
  322. private static string FnSubstringAfter (string arg1, string arg2, CultureInfo ci)
  323. {
  324. int index = ci.CompareInfo.IndexOf (arg1, arg2);
  325. return arg1.Substring (index);
  326. }
  327. public static bool FnMatches (string input, string pattern)
  328. {
  329. return new Regex (pattern).IsMatch (input);
  330. }
  331. [MonoTODO]
  332. public static bool FnMatches (string input, string pattern, string flags)
  333. {
  334. throw new NotImplementedException ();
  335. }
  336. public static string FnReplace (string input, string pattern, string replace)
  337. {
  338. return new Regex (pattern).Replace (input, replace);
  339. }
  340. [MonoTODO]
  341. public static string FnReplace (string input, string pattern, string replace, string flags)
  342. {
  343. throw new NotImplementedException ();
  344. }
  345. public static string [] FnTokenize (string input, string pattern)
  346. {
  347. return new Regex (pattern).Split (input);
  348. }
  349. [MonoTODO]
  350. public static string [] FnTokenize (string input, string pattern, string flags)
  351. {
  352. throw new NotImplementedException ();
  353. }
  354. public static string FnResolveUri (XQueryContext ctx, string relUri)
  355. {
  356. return new Uri (new Uri (ctx.StaticContext.BaseUri), relUri).ToString ();
  357. }
  358. public static string FnResolveUri (string relUri, string baseUri)
  359. {
  360. return new Uri (new Uri (baseUri), relUri).ToString ();
  361. }
  362. public static object FnTrue ()
  363. {
  364. return true;
  365. }
  366. public static object FnFalse ()
  367. {
  368. return false;
  369. }
  370. public static object FnNot (bool value)
  371. {
  372. return !value;
  373. }
  374. // FIXME: add a bunch of annoying datetime functions
  375. [MonoTODO]
  376. public static object FnResolveQName ()
  377. {
  378. throw new NotImplementedException ();
  379. }
  380. [MonoTODO]
  381. public static object FnExpandQName ()
  382. {
  383. throw new NotImplementedException ();
  384. }
  385. public static string FnLocalNameFromQName (XmlQualifiedName name)
  386. {
  387. return name != null ? name.Name : null;
  388. }
  389. public static object FnNamespaceUriFromQName (XmlQualifiedName name)
  390. {
  391. return name != null ? name.Namespace : null;
  392. }
  393. public static object FnNamespaceUriForPrefix (XQueryContext context, string prefix)
  394. {
  395. return prefix != null ? context.LookupNamespace (prefix) : null;
  396. }
  397. public static string [] FnInScopePrefixes (XQueryContext context)
  398. {
  399. IDictionary dict = context.GetNamespacesInScope (XmlNamespaceScope.ExcludeXml);
  400. ArrayList keys = new ArrayList (dict.Keys);
  401. return keys.ToArray (typeof (string)) as string [];
  402. }
  403. public static string FnName (XPathNavigator nav)
  404. {
  405. return nav != null ? nav.Name : null;
  406. }
  407. public static string FnLocalName (XPathNavigator nav)
  408. {
  409. return nav != null ? nav.LocalName : null;
  410. }
  411. public static string FnNamespaceUri (XPathNavigator nav)
  412. {
  413. return nav != null ? nav.NamespaceURI : null;
  414. }
  415. public static double FnNumber (XQueryContext ctx)
  416. {
  417. return FnNumber (ctx.CurrentItem);
  418. }
  419. public static double FnNumber (XPathItem item)
  420. {
  421. if (item == null)
  422. throw new XmlQueryException ("Context item could not be ndetermined during number() evaluation.");
  423. return XQueryConvert.ItemToDouble (item);
  424. }
  425. public static bool FnLang (XQueryContext ctx, string testLang)
  426. {
  427. return FnLang (testLang, ctx.CurrentNode);
  428. }
  429. public static bool FnLang (string testLang, XPathNavigator node)
  430. {
  431. return testLang == node.XmlLang;
  432. }
  433. public static XPathNavigator FnRoot (XQueryContext ctx)
  434. {
  435. if (ctx.CurrentItem == null)
  436. throw new XmlQueryException ("FONC0001: Undefined context item.");
  437. if (ctx.CurrentNode == null)
  438. throw new XmlQueryException ("FOTY0011: Context item is not a node.");
  439. return FnRoot (ctx.CurrentNode);
  440. }
  441. public static XPathNavigator FnRoot (XPathNavigator node)
  442. {
  443. if (node == null)
  444. return null;
  445. XPathNavigator root = node.Clone ();
  446. root.MoveToRoot ();
  447. return root;
  448. }
  449. public static bool FnBoolean (IEnumerator e)
  450. {
  451. if (!e.MoveNext ())
  452. return false;
  453. XPathItem item = e.Current as XPathItem;
  454. if (e.MoveNext ())
  455. return true;
  456. return XQueryConvert.ItemToBoolean (item);
  457. }
  458. public static IEnumerable FnIndexOf (XQueryContext ctx, IEnumerable e, XPathItem item)
  459. {
  460. return FnIndexOf (e, item, ctx.DefaultCollation);
  461. }
  462. public static IEnumerable FnIndexOf (IEnumerable items, XPathItem item, CultureInfo ci)
  463. {
  464. ArrayList al = new ArrayList ();
  465. IEnumerator e = items.GetEnumerator ();
  466. for (int i = 0; e.MoveNext (); i++) {
  467. XPathItem iter = e.Current as XPathItem;
  468. if (iter.XmlType.TypeCode == XmlTypeCode.String) {
  469. if (ci.CompareInfo.Compare (iter.Value, item.Value) == 0)
  470. al.Add (i);
  471. }
  472. else {
  473. IComparable ic = (IComparable) iter.TypedValue;
  474. if (ic.CompareTo ((IComparable) item.TypedValue) == 0)
  475. al.Add (i);
  476. }
  477. }
  478. return al;
  479. }
  480. public static bool FnEmpty (IEnumerable e)
  481. {
  482. if (e is XPathEmptySequence)
  483. return true;
  484. return !e.GetEnumerator ().MoveNext ();
  485. }
  486. public static object FnExists (IEnumerable e)
  487. {
  488. if (e is XPathEmptySequence)
  489. return false;
  490. return e.GetEnumerator ().MoveNext ();
  491. }
  492. [MonoTODO]
  493. public static object FnDistinctValues (XQueryContext ctx, IEnumerable items)
  494. {
  495. throw new NotImplementedException ();
  496. }
  497. [MonoTODO]
  498. public static object FnDistinctValues (XQueryContext ctx, IEnumerable items, string collation)
  499. {
  500. throw new NotImplementedException ();
  501. }
  502. [MonoTODO]
  503. public static IEnumerable FnInsertBefore (IEnumerable target, int position, IEnumerable inserts)
  504. {
  505. throw new NotImplementedException ();
  506. }
  507. [MonoTODO]
  508. public static IEnumerable FnRemove (IEnumerable target, int position)
  509. {
  510. throw new NotImplementedException ();
  511. }
  512. [MonoTODO]
  513. public static IEnumerable FnReverse (IEnumerable arg)
  514. {
  515. throw new NotImplementedException ();
  516. }
  517. [MonoTODO]
  518. public static object FnSubsequence (IEnumerable sourceSeq, double startingLoc)
  519. {
  520. throw new NotImplementedException ();
  521. }
  522. [MonoTODO]
  523. public static object FnSubsequence (IEnumerable sourceSeq, double startingLoc, double length)
  524. {
  525. throw new NotImplementedException ();
  526. }
  527. [MonoTODO]
  528. // Basically it should be optimized by XQueryASTCompiler
  529. public static IEnumerable FnUnordered (IEnumerable e)
  530. {
  531. return e;
  532. }
  533. [MonoTODO]
  534. public static object FnZeroOrMore (IEnumerable e)
  535. {
  536. throw new NotImplementedException ();
  537. }
  538. [MonoTODO]
  539. public static object FnOneOrMore (IEnumerable e)
  540. {
  541. throw new NotImplementedException ();
  542. }
  543. [MonoTODO]
  544. public static object FnExactlyOne (IEnumerable e)
  545. {
  546. throw new NotImplementedException ();
  547. }
  548. [MonoTODO]
  549. public static object FnDeepEqual (XQueryContext ctx, IEnumerable p1, IEnumerable p2)
  550. {
  551. throw new NotImplementedException ();
  552. }
  553. [MonoTODO]
  554. public static object FnDeepEqual (XQueryContext ctx, IEnumerable p1, IEnumerable p2, string collation)
  555. {
  556. throw new NotImplementedException ();
  557. }
  558. [MonoTODO]
  559. public static object FnCount (IEnumerable e)
  560. {
  561. throw new NotImplementedException ();
  562. }
  563. [MonoTODO]
  564. public static object FnAvg (IEnumerable e)
  565. {
  566. throw new NotImplementedException ();
  567. }
  568. [MonoTODO]
  569. public static object FnMax (XQueryContext ctx, IEnumerable e)
  570. {
  571. throw new NotImplementedException ();
  572. }
  573. [MonoTODO]
  574. public static object FnMax (XQueryContext ctx, IEnumerable e, string collation)
  575. {
  576. throw new NotImplementedException ();
  577. }
  578. [MonoTODO]
  579. public static object FnMin (XQueryContext ctx, IEnumerable e)
  580. {
  581. throw new NotImplementedException ();
  582. }
  583. [MonoTODO]
  584. public static object FnMin (XQueryContext ctx, IEnumerable e, string collation)
  585. {
  586. throw new NotImplementedException ();
  587. }
  588. [MonoTODO]
  589. public static object FnSum (IEnumerable e)
  590. {
  591. throw new NotImplementedException ();
  592. }
  593. [MonoTODO]
  594. public static object FnSum (IEnumerable e, XPathItem zero)
  595. {
  596. throw new NotImplementedException ();
  597. }
  598. public static XPathNavigator FnId (XQueryContext ctx, string id)
  599. {
  600. return FnId (id, ctx.CurrentNode);
  601. }
  602. public static XPathNavigator FnId (string id, XPathNavigator nav)
  603. {
  604. XPathNavigator node = nav.Clone ();
  605. return node.MoveToId (id) ? node : null;
  606. }
  607. [MonoTODO]
  608. public static object FnIdRef (XQueryContext ctx, string arg)
  609. {
  610. return FnIdRef (arg, ctx.CurrentNode);
  611. }
  612. [MonoTODO]
  613. public static object FnIdRef (string arg, XPathNavigator node)
  614. {
  615. throw new NotImplementedException ();
  616. }
  617. [MonoTODO]
  618. public static object FnDoc (XQueryContext ctx, string uri)
  619. {
  620. throw new NotImplementedException ();
  621. }
  622. public static IEnumerable FnCollection (XQueryContext ctx, string name)
  623. {
  624. return ctx.ResolveCollection (name);
  625. }
  626. public static object FnPosition (XQueryContext ctx)
  627. {
  628. return ctx.CurrentSequence.Position;
  629. }
  630. public static object FnLast (XQueryContext ctx)
  631. {
  632. return ctx.CurrentSequence.Count;
  633. }
  634. public static DateTime FnCurrentDateTime ()
  635. {
  636. return DateTime.Now;
  637. }
  638. public static object FnCurrentDate ()
  639. {
  640. return DateTime.Today;
  641. }
  642. public static object FnCurrentTime ()
  643. {
  644. return DateTime.Now.TimeOfDay;
  645. }
  646. [MonoTODO]
  647. public static object FnDefaultCollation ()
  648. {
  649. throw new NotImplementedException ();
  650. }
  651. [MonoTODO]
  652. public static object FnImplicitTimeZone ()
  653. {
  654. throw new NotImplementedException ();
  655. }
  656. }
  657. }
  658. #endif