EDN Admin
Well-known member
Hi all;
I created a standard XsltContext class and call it as follows:
<div style="color:Black;background-color:White; <pre>
XPathCustomContext context = <span style="color:Blue; new XPathCustomContext(<span style="color:Blue; new NameTable());
context.AddNamespace(<span style="color:#A31515; "windward", XPathCustomContext.Namespace);
XsltArgumentList varList = <span style="color:Blue; new XsltArgumentList();
varList.AddParam(<span style="color:#A31515; "stat-index", <span style="color:#A31515; "", 0);
context.ArgList = varList;
XmlDocument doc = <span style="color:Blue; new XmlDocument();
doc.Load(<span style="color:#A31515; "c:\test\order.xml");
<span style="color:Blue; object xx = doc.CreateNavigator().Evaluate(<span style="color:#A31515; "/order[1]/customer[1]/num[@negone = $stat-index]", context);
[/code]
When running under .net 4.0 it works fine. But under .NET 3.5 (which we have to use at present) I get:
<pre>System.Xml.XPath.XPathException was unhandled
Message=XsltContext is needed for this query because of an unknown function.
Source=System.Xml
StackTrace:
at MS.Internal.Xml.XPath.CompiledXpathExpr.UndefinedXsltContext.ResolveVariable(String prefix, String name)
at MS.Internal.Xml.XPath.VariableQuery.SetXsltContext(XsltContext context)
at MS.Internal.Xml.XPath.LogicalExpr.SetXsltContext(XsltContext context)
at MS.Internal.Xml.XPath.FilterQuery.SetXsltContext(XsltContext input)
at MS.Internal.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager nsManager)
at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
at System.Xml.XPath.XPathNavigator.Evaluate(String xpath, IXmlNamespaceResolver resolver)
at CustomXpathFunctions.Program.Main(String[] args) in c:srcCustomXpathFunctionsProgram.cs:line 62
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
[/code]
Any idea why?
thanks - dave
<hr class="sig http://www.the-business-intelligence-guy.com/2011/05/the-future-of-bi-raw-uncut.html The future of B.I. - Raw & Uncut
View the full article
I created a standard XsltContext class and call it as follows:
<div style="color:Black;background-color:White; <pre>
XPathCustomContext context = <span style="color:Blue; new XPathCustomContext(<span style="color:Blue; new NameTable());
context.AddNamespace(<span style="color:#A31515; "windward", XPathCustomContext.Namespace);
XsltArgumentList varList = <span style="color:Blue; new XsltArgumentList();
varList.AddParam(<span style="color:#A31515; "stat-index", <span style="color:#A31515; "", 0);
context.ArgList = varList;
XmlDocument doc = <span style="color:Blue; new XmlDocument();
doc.Load(<span style="color:#A31515; "c:\test\order.xml");
<span style="color:Blue; object xx = doc.CreateNavigator().Evaluate(<span style="color:#A31515; "/order[1]/customer[1]/num[@negone = $stat-index]", context);
[/code]
When running under .net 4.0 it works fine. But under .NET 3.5 (which we have to use at present) I get:
<pre>System.Xml.XPath.XPathException was unhandled
Message=XsltContext is needed for this query because of an unknown function.
Source=System.Xml
StackTrace:
at MS.Internal.Xml.XPath.CompiledXpathExpr.UndefinedXsltContext.ResolveVariable(String prefix, String name)
at MS.Internal.Xml.XPath.VariableQuery.SetXsltContext(XsltContext context)
at MS.Internal.Xml.XPath.LogicalExpr.SetXsltContext(XsltContext context)
at MS.Internal.Xml.XPath.FilterQuery.SetXsltContext(XsltContext input)
at MS.Internal.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager nsManager)
at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
at System.Xml.XPath.XPathNavigator.Evaluate(String xpath, IXmlNamespaceResolver resolver)
at CustomXpathFunctions.Program.Main(String[] args) in c:srcCustomXpathFunctionsProgram.cs:line 62
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
[/code]
Any idea why?
thanks - dave
<hr class="sig http://www.the-business-intelligence-guy.com/2011/05/the-future-of-bi-raw-uncut.html The future of B.I. - Raw & Uncut
View the full article