Problem using XPath in Jint

Nov 26, 2012 at 11:05 AM
Edited Nov 26, 2012 at 11:07 AM

Hi everyone,

I encountered a little problem using Xpath in Jint (0.9.2).

I've set a XpathDocument object inside Jint, and i'm triyng to use it inside a script:

jint.SetParameter("XML", new XPathDocument(myXml));
 

Object creation works perfectly.

Now i run the following code:

var navigator = XML.CreateNavigator();
var query = navigator.Compile(""/users/profile[age<25]/name"");
var nodes = navigator.Select(query);
 

The error comes out using "nodes" object.

Any property or method of "nodes" objects falls into the same error.
For example:

var aa = nodes.GetEnumerator();

falls into:

Jint.JintException: Attempt by method 'DynamicClass.dynamicPropertyGetter(Jint.Marshaller, Jint.Native.JsDictionaryObject)' to access method 'Jint.Marshaller.MarshalJsValue<System.Xml.XPath.XPathNodeIterator+Enumerator>(Jint.Native.JsInstance)' failed.

or..

var aa = nodes.Count;

falls into:

Jint.JintException: Attempt by method 'DynamicClass.dynamicPropertyGetter(Jint.Marshaller, Jint.Native.JsDictionaryObject)' to access method 'Jint.Marshaller.MarshalJsValue<MS.Internal.Xml.XPath.XPathSelectionIterator>(Jint.Native.JsInstance)' failed.

--

XPathNodeIterator object is created correctly.. if i returns it, i can use it without problems outside jint.

This same error occurs simply by setting XPathNodeIterator object inside jint and using it.

By looking into jint code the problem pops-out in NativeDescriptor at this point:

public override JsInstance Get(JsDictionaryObject that)
        {
            return getter != null ? getter(that) : JsUndefined.Instance ;
        }
 

which is called by ExecutionVisitor in this check:

if (callTarget != null && callTarget.TryGetProperty(propertyName, out result)) {

in 

public void Visit(PropertyExpression expression) {
 

I've not very clear how it works and i don't know what to do to try solving this situation.

Can someone help me?

Thanks in advance.