Skip to content
Browse files

Added Exslt-related extension methods

  • Loading branch information...
1 parent 6322078 commit b6536ccdf35cd059f8b6bc06288c517eba4db6c6 @tg73 tg73 committed
Showing with 26 additions and 0 deletions.
  1. +25 −0 Library/Main/Source/Exslt/ExsltExtensionMethods.cs
  2. +1 −0 Library/Main/Source/Mvp.Xml.csproj
View
25 Library/Main/Source/Exslt/ExsltExtensionMethods.cs
@@ -0,0 +1,25 @@
+using System.Xml.XPath;
+
+namespace Mvp.Xml.Exslt
+{
+ /// <summary>
+ /// Useful general-purpose extension methods related to the <c>Mvp.Xml.Exsl</c> namespace.
+ /// </summary>
+ public static class ExsltExtensionMethods
+ {
+ /// <summary>
+ /// Evaluate an XPath expression on an <c>IXPathNavigable</c> instance, using the <c>ExsltContext</c> context.
+ /// </summary>
+ /// <param name="xpn">An <c>IXPathNavigable</c> instance.</param>
+ /// <param name="xpath">The XPath epression to be evaluated.</param>
+ /// <returns>The result of the evaluation.</returns>
+ public static object ExsltEvaluate( this IXPathNavigable xpn, string xpath )
+ {
+ XPathNavigator nav = xpn.CreateNavigator();
+ XPathExpression expr = nav.Compile( xpath );
+ ExsltContext ctxt = new ExsltContext( nav.NameTable );
+ expr.SetContext( ctxt );
+ return nav.Evaluate( expr );
+ }
+ }
+}
View
1 Library/Main/Source/Mvp.Xml.csproj
@@ -114,6 +114,7 @@
<Compile Include="Exslt\ExsltContext.cs" />
<Compile Include="Exslt\ExsltContextFunction.cs" />
<Compile Include="Exslt\ExsltDatesAndTimes.cs" />
+ <Compile Include="Exslt\ExsltExtensionMethods.cs" />
<Compile Include="Exslt\ExsltMath.cs" />
<Compile Include="Exslt\ExsltNamespaces.cs" />
<Compile Include="Exslt\ExsltRandom.cs" />

0 comments on commit b6536cc

Please sign in to comment.
Something went wrong with that request. Please try again.