The .net XPath support is for XPath 1.0. However, there is an easy way to add both XPath 2.0 functions (as well as your own). At the same time you can add support for variables where you can do the equivilent of a SetParameter() call on a SQL select call.
Note: I was not able to find a way to add support for inequalities on dates. If anyone knows of a way to add this, please let me know.
You need to create a custom XsltContext. A good reference for this is Adding Custom Functions to XPath.
The code in XPathCustomContext.cs is well documented and straightforward so I'm not going to write about it here. However a couple of notes when using it:
And here's the biggie – you must call all Evaluate() and Select*() calls using XpathExpressions as shown below. If you use the call where you directly pass in the XPath as a string you will get an exception that says you are using an unknown function. This occurs even if you pass in your custom context.
private object SelectSingleNodeTyped(XPathNavigator nav, string select, XsltArgumentList parameters)
myContext.ArgList = parameters;
XPathExpression exp = nav.Compile(myXPathSelect);
object obj = nav.Evaluate(exp);