Skip to content

Iterator content is missing in variable #6

@nverwer

Description

@nverwer

Node iterators do not work correctly when one of the items is a variable containing the result of a previous XPath2 evaluation. I added the following test to XPath2ExtensionsTest (not the right place):

    public void XPath2_IteratorWithVariableTest()
    {
        System.Collections.Generic.Dictionary<XmlQualifiedName, object> vars = new System.Collections.Generic.Dictionary<XmlQualifiedName, object>();
        var nav = GetTodoListDoc().CreateNavigator();
        var prov = new NodeProvider(nav);
        var result = nav.XPath2Evaluate("/todo-list/todo-item[1]");
        vars[new XmlQualifiedName("x")] = result;
        var expr = XPath2Expression.Compile("($x, /todo-list/todo-item[2])");
        result = expr.Evaluate(prov, vars);
        vars[new XmlQualifiedName("y")] = result;
        expr = XPath2Expression.Compile("($y, /todo-list/todo-item[3])");
        result = expr.Evaluate(prov, vars);
        vars[new XmlQualifiedName("z")] = result;
    }

After every evaluation, the result contains only one item, which is the selected node. I would expect the result to contain 3 items at the end. The contents of the variable are lost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions