EDN Admin
Well-known member
Hi all;
I am able to do selects with namespaces. And I can do sorts without namespaces. But I am getting an error if I try to do a select using a sort where the sorted node has a namespace. Heres my code (extra stuff pulled out):
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; internal XPathNodeIterator SelectNodes(XPathNavigator nav, <span style="color:Blue; string xpath, <span style="color:Blue; string sortXPath)
{
XPathExpression expr = nav.Compile(xpath);
<span style="color:Blue; if (!<span style="color:Blue; string.IsNullOrEmpty(sortXPath))
expr.AddSort(sortXPath, XmlSortOrder.Ascending, XmlCaseOrder.None, <span style="color:#A31515; "", XmlDataType.Text);
<span style="color:Blue; return nav.Select(expr);
}
[/code]
The Select() call throws:
<pre>System.Xml.XPath.XPathException occurred
Message=Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
Source=System.Xml
StackTrace:
at MS.Internal.Xml.XPath.CompiledXpathExpr.get_QueryTree()
at System.Xml.XPath.XPathNavigator.Evaluate(XPathExpression expr, XPathNodeIterator context)
at System.Xml.XPath.XPathNavigator.Evaluate(XPathExpression expr)
at System.Xml.XPath.XPathNavigator.Select(XPathExpression expr)
at WindwardReportsDrivers.net.windward.datasource.xml.XPathDataSource.XPathDocNode.SelectNodes(XPathNavigator nav, String xpath, XsltArgumentList parameters)
InnerException:
[/code]
Any idea why? This code works fine if no sortXPath is passed for xpath both with and without namespaces. So I am confident that expr.SetContext() is setting the correct namespaces. I also looked at the
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small parentDatasource.context
name table using the debugger and the prefix and uri are both in there.
??? - 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 am able to do selects with namespaces. And I can do sorts without namespaces. But I am getting an error if I try to do a select using a sort where the sorted node has a namespace. Heres my code (extra stuff pulled out):
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; internal XPathNodeIterator SelectNodes(XPathNavigator nav, <span style="color:Blue; string xpath, <span style="color:Blue; string sortXPath)
{
XPathExpression expr = nav.Compile(xpath);
<span style="color:Blue; if (!<span style="color:Blue; string.IsNullOrEmpty(sortXPath))
expr.AddSort(sortXPath, XmlSortOrder.Ascending, XmlCaseOrder.None, <span style="color:#A31515; "", XmlDataType.Text);
<span style="color:Blue; return nav.Select(expr);
}
[/code]
The Select() call throws:
<pre>System.Xml.XPath.XPathException occurred
Message=Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
Source=System.Xml
StackTrace:
at MS.Internal.Xml.XPath.CompiledXpathExpr.get_QueryTree()
at System.Xml.XPath.XPathNavigator.Evaluate(XPathExpression expr, XPathNodeIterator context)
at System.Xml.XPath.XPathNavigator.Evaluate(XPathExpression expr)
at System.Xml.XPath.XPathNavigator.Select(XPathExpression expr)
at WindwardReportsDrivers.net.windward.datasource.xml.XPathDataSource.XPathDocNode.SelectNodes(XPathNavigator nav, String xpath, XsltArgumentList parameters)
InnerException:
[/code]
Any idea why? This code works fine if no sortXPath is passed for xpath both with and without namespaces. So I am confident that expr.SetContext() is setting the correct namespaces. I also looked at the
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small parentDatasource.context
name table using the debugger and the prefix and uri are both in there.
??? - 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