XQueryFunctionCliImpl.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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 null;
  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. throw new XmlQueryException ("Function nilled() does not allow empty sequence parameter.");
  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. [MonoTODO]
  113. public static string FnString (object arg)
  114. {
  115. if (arg == null)
  116. return String.Empty;
  117. XPathNavigator nav = arg as XPathNavigator;
  118. if (nav != null)
  119. return nav.Value;
  120. // FIXME: it should be exactly the same as "arg cast as xs:string"
  121. XPathItem item = ToItem (arg);
  122. return item != null ? XQueryConvert.ItemToString (item) : null;
  123. }
  124. [MonoTODO]
  125. public static XPathAtomicValue FnData (object arg)
  126. {
  127. // FIXME: parameter should be object []
  128. XPathNavigator nav = arg as XPathNavigator;
  129. if (nav != null) {
  130. XmlSchemaType st = nav.SchemaInfo != null ? nav.SchemaInfo.SchemaType : null;
  131. return new XPathAtomicValue (nav.TypedValue, st != null ? st : XmlSchemaComplexType.AnyType);
  132. }
  133. else
  134. return (XPathAtomicValue) arg;
  135. }
  136. public static string FnBaseUri (XPathNavigator nav)
  137. {
  138. return nav != null ? nav.BaseURI : null;
  139. }
  140. public static string FnDocumentUri (XPathNavigator nav)
  141. {
  142. if (nav == null)
  143. return null;
  144. XPathNavigator root = nav.Clone ();
  145. root.MoveToRoot ();
  146. return root.BaseURI;
  147. }
  148. // Error
  149. [MonoTODO]
  150. public static void FnError (object arg)
  151. {
  152. throw new NotImplementedException ();
  153. }
  154. // Trace
  155. [MonoTODO]
  156. public static object FnTrace (object arg)
  157. {
  158. throw new NotImplementedException ();
  159. }
  160. // Numeric Operation
  161. [MonoTODO]
  162. public static object FnAbs (object arg)
  163. {
  164. if (arg is int)
  165. return System.Math.Abs ((int) arg);
  166. if (arg is long)
  167. return System.Math.Abs ((long) arg);
  168. else if (arg is decimal)
  169. return System.Math.Abs ((decimal) arg);
  170. else if (arg is double)
  171. return System.Math.Abs ((double) arg);
  172. else if (arg is float)
  173. return System.Math.Abs ((float) arg);
  174. else if (arg is short)
  175. return System.Math.Abs ((short) arg);
  176. else if (arg is uint || arg is ulong || arg is ushort)
  177. return arg;
  178. return null;
  179. }
  180. [MonoTODO]
  181. public static object FnCeiling (object arg)
  182. {
  183. if (arg is decimal) {
  184. decimal d = (decimal) arg;
  185. decimal d2 = Decimal.Floor (d);
  186. return d2 != d ? d2 + 1 : d2;
  187. }
  188. else if (arg is double || arg is float)
  189. return System.Math.Ceiling ((double) arg);
  190. else if (arg is int || arg is long || arg is short || arg is uint || arg is ulong || arg is ushort)
  191. return arg;
  192. return null;
  193. }
  194. [MonoTODO]
  195. public static object FnFloor (object arg)
  196. {
  197. if (arg is decimal)
  198. return Decimal.Floor ((decimal) arg);
  199. else if (arg is double || arg is float)
  200. return System.Math.Floor ((double) arg);
  201. else if (arg is int || arg is long || arg is short || arg is uint || arg is ulong || arg is ushort)
  202. return arg;
  203. return null;
  204. }
  205. [MonoTODO]
  206. public static object FnRound (object arg)
  207. {
  208. if (arg is decimal)
  209. return Decimal.Round ((decimal) arg, 0);
  210. else if (arg is double || arg is float)
  211. return System.Math.Round ((double) arg);
  212. else if (arg is int || arg is long || arg is short || arg is uint || arg is ulong || arg is ushort)
  213. return arg;
  214. return null;
  215. }
  216. [MonoTODO]
  217. public static object FnRoundHalfToEven (object arg)
  218. {
  219. throw new NotImplementedException ();
  220. }
  221. [MonoTODO]
  222. public static string FnCodepointsToString (int [] arg)
  223. {
  224. throw new NotImplementedException ();
  225. }
  226. [MonoTODO]
  227. public static int [] FnStringToCodepoints (string arg)
  228. {
  229. throw new NotImplementedException ();
  230. }
  231. public static int FnCompare (XQueryContext ctx, string s1, string s2)
  232. {
  233. return FnCompare (s1, s2, ctx.DefaultCollation);
  234. }
  235. public static int FnCompare (XQueryContext ctx, string s1, string s2, string collation)
  236. {
  237. return FnCompare (s1, s2, ctx.GetCulture (collation));
  238. }
  239. private static int FnCompare (string s1, string s2, CultureInfo ci)
  240. {
  241. return ci.CompareInfo.Compare (s1, s2);
  242. }
  243. public static string FnConcat (object o1, object o2)
  244. {
  245. return String.Concat (o1, o2);
  246. }
  247. public static string FnStringJoin (string [] strings, string separator)
  248. {
  249. return String.Join (separator, strings);
  250. }
  251. public static string FnSubstring (string src, double loc)
  252. {
  253. return src.Substring ((int) loc);
  254. }
  255. public static string FnSubstring (string src, double loc, double length)
  256. {
  257. return src.Substring ((int) loc, (int) length);
  258. }
  259. public static int FnStringLength (XQueryContext ctx)
  260. {
  261. return FnString (ctx).Length;
  262. }
  263. public static int FnStringLength (string s)
  264. {
  265. return s.Length;
  266. }
  267. public static string FnNormalizeSpace (XQueryContext ctx)
  268. {
  269. return FnNormalizeSpace (FnString (ctx));
  270. }
  271. [MonoTODO]
  272. public static string FnNormalizeSpace (string s)
  273. {
  274. throw new NotImplementedException ();
  275. }
  276. public static string FnNormalizeUnicode (string arg)
  277. {
  278. return FnNormalizeUnicode (arg, "NFC");
  279. }
  280. [MonoTODO]
  281. public static string FnNormalizeUnicode (string arg, string normalizationForm)
  282. {
  283. throw new NotImplementedException ();
  284. }
  285. public static string FnUpperCase (string arg)
  286. {
  287. // FIXME: supply culture
  288. return arg.ToUpper ();
  289. }
  290. public static string FnLowerCase (string arg)
  291. {
  292. // FIXME: supply culture
  293. return arg.ToLower ();
  294. }
  295. public static string FnTranslate (string arg, string mapString, string transString)
  296. {
  297. return arg == null ? null : arg.Replace (mapString, transString);
  298. }
  299. [MonoTODO]
  300. public static string FnEscapeUri (string uriPart, bool escapeReserved)
  301. {
  302. throw new NotImplementedException ();
  303. }
  304. public static bool FnContains (XQueryContext ctx, string arg1, string arg2)
  305. {
  306. return FnContains (arg1, arg2, ctx.DefaultCollation);
  307. }
  308. public static bool FnContains (XQueryContext ctx, string arg1, string arg2, string collation)
  309. {
  310. return FnContains (arg1, arg2, ctx.GetCulture (collation));
  311. }
  312. private static bool FnContains (string arg1, string arg2, CultureInfo ci)
  313. {
  314. if (arg1 == null)
  315. arg1 = String.Empty;
  316. if (arg2 == null)
  317. arg2 = String.Empty;
  318. if (arg2 == String.Empty)
  319. return true;
  320. return ci.CompareInfo.IndexOf (arg1, arg2) >= 0;
  321. }
  322. public static bool FnStartsWith (XQueryContext ctx, string arg1, string arg2)
  323. {
  324. return FnStartsWith (arg1, arg2, ctx.DefaultCollation);
  325. }
  326. public static bool FnStartsWith (XQueryContext ctx, string arg1, string arg2, string collation)
  327. {
  328. return FnStartsWith (arg1, arg2, ctx.GetCulture (collation));
  329. }
  330. private static bool FnStartsWith (string arg1, string arg2, CultureInfo ci)
  331. {
  332. return ci.CompareInfo.IsPrefix (arg1, arg2);
  333. }
  334. public static bool FnEndsWith (XQueryContext ctx, string arg1, string arg2)
  335. {
  336. return FnEndsWith (arg1, arg2, ctx.DefaultCollation);
  337. }
  338. public static bool FnEndsWith (XQueryContext ctx, string arg1, string arg2, string collation)
  339. {
  340. return FnEndsWith (arg1, arg2, ctx.GetCulture (collation));
  341. }
  342. private static bool FnEndsWith (string arg1, string arg2, CultureInfo ci)
  343. {
  344. return ci.CompareInfo.IsSuffix (arg1, arg2);
  345. }
  346. public static string FnSubstringBefore (XQueryContext ctx, string arg1, string arg2)
  347. {
  348. return FnSubstringBefore (arg1, arg2, ctx.DefaultCollation);
  349. }
  350. public static string FnSubstringBefore (XQueryContext ctx, string arg1, string arg2, string collation)
  351. {
  352. return FnSubstringBefore (arg1, arg2, ctx.GetCulture (collation));
  353. }
  354. private static string FnSubstringBefore (string arg1, string arg2, CultureInfo ci)
  355. {
  356. int index = ci.CompareInfo.IndexOf (arg1, arg2);
  357. return arg1.Substring (0, index);
  358. }
  359. public static string FnSubstringAfter (XQueryContext ctx, string arg1, string arg2)
  360. {
  361. return FnSubstringAfter (arg1, arg2, ctx.DefaultCollation);
  362. }
  363. public static string FnSubstringAfter (XQueryContext ctx, string arg1, string arg2, string collation)
  364. {
  365. return FnSubstringAfter (arg1, arg2, ctx.GetCulture (collation));
  366. }
  367. private static string FnSubstringAfter (string arg1, string arg2, CultureInfo ci)
  368. {
  369. int index = ci.CompareInfo.IndexOf (arg1, arg2);
  370. return arg1.Substring (index);
  371. }
  372. public static bool FnMatches (string input, string pattern)
  373. {
  374. return new Regex (pattern).IsMatch (input);
  375. }
  376. [MonoTODO]
  377. public static bool FnMatches (string input, string pattern, string flags)
  378. {
  379. throw new NotImplementedException ();
  380. }
  381. public static string FnReplace (string input, string pattern, string replace)
  382. {
  383. return new Regex (pattern).Replace (input, replace);
  384. }
  385. [MonoTODO]
  386. public static string FnReplace (string input, string pattern, string replace, string flags)
  387. {
  388. throw new NotImplementedException ();
  389. }
  390. public static string [] FnTokenize (string input, string pattern)
  391. {
  392. return new Regex (pattern).Split (input);
  393. }
  394. [MonoTODO]
  395. public static string [] FnTokenize (string input, string pattern, string flags)
  396. {
  397. throw new NotImplementedException ();
  398. }
  399. public static string FnResolveUri (XQueryContext ctx, string relUri)
  400. {
  401. return new Uri (new Uri (ctx.StaticContext.BaseUri), relUri).ToString ();
  402. }
  403. public static string FnResolveUri (string relUri, string baseUri)
  404. {
  405. return new Uri (new Uri (baseUri), relUri).ToString ();
  406. }
  407. public static object FnTrue ()
  408. {
  409. return true;
  410. }
  411. public static object FnFalse ()
  412. {
  413. return false;
  414. }
  415. public static object FnNot (bool value)
  416. {
  417. return !value;
  418. }
  419. // FIXME: add a bunch of annoying datetime functions
  420. [MonoTODO]
  421. public static object FnResolveQName ()
  422. {
  423. throw new NotImplementedException ();
  424. }
  425. [MonoTODO]
  426. public static object FnExpandQName ()
  427. {
  428. throw new NotImplementedException ();
  429. }
  430. public static string FnLocalNameFromQName (XmlQualifiedName name)
  431. {
  432. return name != null ? name.Name : null;
  433. }
  434. public static object FnNamespaceUriFromQName (XmlQualifiedName name)
  435. {
  436. return name != null ? name.Namespace : null;
  437. }
  438. public static object FnNamespaceUriForPrefix (XQueryContext context, string prefix)
  439. {
  440. return prefix != null ? context.LookupNamespace (prefix) : null;
  441. }
  442. public static string [] FnInScopePrefixes (XQueryContext context)
  443. {
  444. IDictionary dict = context.GetNamespacesInScope (XmlNamespaceScope.ExcludeXml);
  445. ArrayList keys = new ArrayList (dict.Keys);
  446. return keys.ToArray (typeof (string)) as string [];
  447. }
  448. public static string FnName (XPathNavigator nav)
  449. {
  450. return nav != null ? nav.Name : null;
  451. }
  452. public static string FnLocalName (XPathNavigator nav)
  453. {
  454. return nav != null ? nav.LocalName : null;
  455. }
  456. public static string FnNamespaceUri (XPathNavigator nav)
  457. {
  458. return nav != null ? nav.NamespaceURI : null;
  459. }
  460. public static double FnNumber (XQueryContext ctx)
  461. {
  462. return FnNumber (ctx.CurrentItem);
  463. }
  464. public static double FnNumber (object arg)
  465. {
  466. if (arg == null)
  467. throw new XmlQueryException ("Context item could not be ndetermined during number() evaluation.");
  468. XPathItem item = ToItem (arg);
  469. return XQueryConvert.ItemToDouble (item);
  470. }
  471. public static bool FnLang (XQueryContext ctx, string testLang)
  472. {
  473. return FnLang (testLang, ctx.CurrentNode);
  474. }
  475. public static bool FnLang (string testLang, XPathNavigator node)
  476. {
  477. return testLang == node.XmlLang;
  478. }
  479. public static XPathNavigator FnRoot (XQueryContext ctx)
  480. {
  481. if (ctx.CurrentItem == null)
  482. throw new XmlQueryException ("FONC0001: Undefined context item.");
  483. if (ctx.CurrentNode == null)
  484. throw new XmlQueryException ("FOTY0011: Context item is not a node.");
  485. return FnRoot (ctx.CurrentNode);
  486. }
  487. public static XPathNavigator FnRoot (XPathNavigator node)
  488. {
  489. if (node == null)
  490. return null;
  491. XPathNavigator root = node.Clone ();
  492. root.MoveToRoot ();
  493. return root;
  494. }
  495. public static bool FnBoolean (IEnumerator e)
  496. {
  497. if (!e.MoveNext ())
  498. return false;
  499. XPathItem item = e.Current as XPathItem;
  500. if (e.MoveNext ())
  501. return true;
  502. return XQueryConvert.ItemToBoolean (item);
  503. }
  504. public static IEnumerable FnIndexOf (XQueryContext ctx, IEnumerable e, XPathItem item)
  505. {
  506. return FnIndexOf (e, item, ctx.DefaultCollation);
  507. }
  508. public static IEnumerable FnIndexOf (IEnumerable items, XPathItem item, CultureInfo ci)
  509. {
  510. ArrayList al = new ArrayList ();
  511. IEnumerator e = items.GetEnumerator ();
  512. for (int i = 0; e.MoveNext (); i++) {
  513. XPathItem iter = e.Current as XPathItem;
  514. if (iter.XmlType.TypeCode == XmlTypeCode.String) {
  515. if (ci.CompareInfo.Compare (iter.Value, item.Value) == 0)
  516. al.Add (i);
  517. }
  518. else {
  519. IComparable ic = (IComparable) iter.TypedValue;
  520. if (ic.CompareTo ((IComparable) item.TypedValue) == 0)
  521. al.Add (i);
  522. }
  523. }
  524. return al;
  525. }
  526. public static bool FnEmpty (IEnumerable e)
  527. {
  528. if (e is XPathEmptySequence)
  529. return true;
  530. return !e.GetEnumerator ().MoveNext ();
  531. }
  532. public static object FnExists (IEnumerable e)
  533. {
  534. if (e is XPathEmptySequence)
  535. return false;
  536. return e.GetEnumerator ().MoveNext ();
  537. }
  538. [MonoTODO]
  539. public static object FnDistinctValues (XQueryContext ctx, IEnumerable items)
  540. {
  541. throw new NotImplementedException ();
  542. }
  543. [MonoTODO]
  544. public static object FnDistinctValues (XQueryContext ctx, IEnumerable items, string collation)
  545. {
  546. throw new NotImplementedException ();
  547. }
  548. [MonoTODO]
  549. public static IEnumerable FnInsertBefore (IEnumerable target, int position, IEnumerable inserts)
  550. {
  551. throw new NotImplementedException ();
  552. }
  553. [MonoTODO]
  554. public static IEnumerable FnRemove (IEnumerable target, int position)
  555. {
  556. throw new NotImplementedException ();
  557. }
  558. [MonoTODO]
  559. public static IEnumerable FnReverse (IEnumerable arg)
  560. {
  561. throw new NotImplementedException ();
  562. }
  563. [MonoTODO]
  564. public static object FnSubsequence (IEnumerable sourceSeq, double startingLoc)
  565. {
  566. throw new NotImplementedException ();
  567. }
  568. [MonoTODO]
  569. public static object FnSubsequence (IEnumerable sourceSeq, double startingLoc, double length)
  570. {
  571. throw new NotImplementedException ();
  572. }
  573. [MonoTODO]
  574. // Basically it should be optimized by XQueryASTCompiler
  575. public static IEnumerable FnUnordered (IEnumerable e)
  576. {
  577. return e;
  578. }
  579. [MonoTODO]
  580. public static object FnZeroOrMore (IEnumerable e)
  581. {
  582. throw new NotImplementedException ();
  583. }
  584. [MonoTODO]
  585. public static object FnOneOrMore (IEnumerable e)
  586. {
  587. throw new NotImplementedException ();
  588. }
  589. [MonoTODO]
  590. public static object FnExactlyOne (IEnumerable e)
  591. {
  592. throw new NotImplementedException ();
  593. }
  594. [MonoTODO]
  595. public static object FnDeepEqual (XQueryContext ctx, IEnumerable p1, IEnumerable p2)
  596. {
  597. throw new NotImplementedException ();
  598. }
  599. [MonoTODO]
  600. public static object FnDeepEqual (XQueryContext ctx, IEnumerable p1, IEnumerable p2, string collation)
  601. {
  602. throw new NotImplementedException ();
  603. }
  604. [MonoTODO]
  605. public static object FnCount (IEnumerable e)
  606. {
  607. throw new NotImplementedException ();
  608. }
  609. [MonoTODO]
  610. public static object FnAvg (IEnumerable e)
  611. {
  612. throw new NotImplementedException ();
  613. }
  614. [MonoTODO]
  615. public static object FnMax (XQueryContext ctx, IEnumerable e)
  616. {
  617. throw new NotImplementedException ();
  618. }
  619. [MonoTODO]
  620. public static object FnMax (XQueryContext ctx, IEnumerable e, string collation)
  621. {
  622. throw new NotImplementedException ();
  623. }
  624. [MonoTODO]
  625. public static object FnMin (XQueryContext ctx, IEnumerable e)
  626. {
  627. throw new NotImplementedException ();
  628. }
  629. [MonoTODO]
  630. public static object FnMin (XQueryContext ctx, IEnumerable e, string collation)
  631. {
  632. throw new NotImplementedException ();
  633. }
  634. [MonoTODO]
  635. public static object FnSum (IEnumerable e)
  636. {
  637. throw new NotImplementedException ();
  638. }
  639. [MonoTODO]
  640. public static object FnSum (IEnumerable e, XPathItem zero)
  641. {
  642. throw new NotImplementedException ();
  643. }
  644. public static XPathNavigator FnId (XQueryContext ctx, string id)
  645. {
  646. return FnId (id, ctx.CurrentNode);
  647. }
  648. public static XPathNavigator FnId (string id, XPathNavigator nav)
  649. {
  650. XPathNavigator node = nav.Clone ();
  651. return node.MoveToId (id) ? node : null;
  652. }
  653. [MonoTODO]
  654. public static object FnIdRef (XQueryContext ctx, string arg)
  655. {
  656. return FnIdRef (arg, ctx.CurrentNode);
  657. }
  658. [MonoTODO]
  659. public static object FnIdRef (string arg, XPathNavigator node)
  660. {
  661. throw new NotImplementedException ();
  662. }
  663. [MonoTODO]
  664. public static object FnDoc (XQueryContext ctx, string uri)
  665. {
  666. throw new NotImplementedException ();
  667. }
  668. public static IEnumerable FnCollection (XQueryContext ctx, string name)
  669. {
  670. return ctx.ResolveCollection (name);
  671. }
  672. public static int FnPosition (XQueryContext ctx)
  673. {
  674. return ctx.CurrentSequence.Position;
  675. }
  676. public static int FnLast (XQueryContext ctx)
  677. {
  678. return ctx.CurrentSequence.Count;
  679. }
  680. public static DateTime FnCurrentDateTime ()
  681. {
  682. return DateTime.Now;
  683. }
  684. public static DateTime FnCurrentDate ()
  685. {
  686. return DateTime.Today;
  687. }
  688. public static DateTime FnCurrentTime ()
  689. {
  690. return new DateTime (DateTime.Now.TimeOfDay.Ticks);
  691. }
  692. [MonoTODO]
  693. public static object FnDefaultCollation ()
  694. {
  695. throw new NotImplementedException ();
  696. }
  697. [MonoTODO]
  698. public static object FnImplicitTimeZone ()
  699. {
  700. throw new NotImplementedException ();
  701. }
  702. }
  703. }
  704. #endif