I am trying to evaluate a XPathExpression with XQSharp and get the Error:"Type check error. The empty sequence cannot b开发者_Python百科e cast to type 'xs:integer'."
AltovaXMLSpy evaluates it correct as "true".
oXmlDoc.CreateNavigator().XPathEvaluate("root/foo/bar cast as xs:integer lt count(root/blah/blub)", oNamespaseManager).ToString()
This XML looks like this:
<root xmlns:xs="http://www.w3.org/2001/XMLSchema">
<foo>
<bar>0</bar>
</foo>
<blah>
<blub/>
</blah>
</root>
What am I missing?
The path expression "root/foo/bar" must not be returning any nodes.
Does the default namespace in your namespace manager match the default namespace of the document?
You could try testing this part of the path expression with the .NET XPath functions to ensure that you are returning the correct nodes:
oXmlDoc.CreateNavigator().Evaluate("root/foo/bar", oNamespaceManager)
Update:
there is no .NET - provided XPath engine that supports XPath 2.0.
Initial reply:
oXmlDoc.CreateNavigator()
.XPathEvaluate("root/foo/bar cast as xs:integer lt count(root/blah/blub)",
oNamespaseManager
)
.ToString()
Most probably the actual XML document, against which the XPath expression is evaluated is not the one you provided, or the current (context) node is not the document-node.
精彩评论