StefH / XPath2.Net

Lightweight XPath2 for .NET
Microsoft Public License
36 stars 14 forks source link

Custom functions during XPath2Expression.Compile #38

Closed binarycow closed 4 years ago

binarycow commented 4 years ago

Is there a way to compile custom functions during XPath2Expression.Compile ?

binarycow commented 4 years ago

Disregard! I figured it out!

public static object CustomFunction(XPath2Context context, IContextProvider provider, object[] args)
{
    throw new NotImplementedException();
}
static void Main(string[] args)
{
    FunctionTable.Inst.Add("urn:my:namespace", "customFunction", XPath2ResultType.Navigator, CustomFunction, false);
    var expr = XPath2Expression.Compile("customFunction()", new YangContext());
}
StefH commented 4 years ago

@binarycow See also https://github.com/StefH/XPath2.Net/tree/master/src/XPath2.Extensions