I am working on a project and I need to extend the XPath validation. This is based on already existing code (that somebody else wrote) and apparently comes from the following code project:
What I understand is that here they make use of an XML document strSample (line 378) to validate the XPath expression. I now need to extend this so that expression like /caseFileModel/DateToResearch + xs:dayTimeDuration('P30s') also can be validated. When I now try to parse such an expression I get the following error:
"Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."
I tried using a Namespace manager:
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("xs", "http://www.w3.org/2005/xpath-functions");
and replaced line 252 with
case XPathResultType.Number: strResult = string.Format("{0}", xpathNav.Evaluate(expression, nsmgr));
break;
but then I got another error:
"XsltContext is needed for this query because of an unknown function."
So my question is whether somebody can explain me how the validation happens and how I can extend it?