Menu

#81 NPE at Assignation.evaluateVariable

v1.0_(example)
open
nobody
None
1
2016-04-05
2016-04-05
Anonymous
No

Saxon 9.7.0-4. I run the following query:

declare namespace s=\"http://tpox-benchmark.com/security\";
declare namespace c=\"http://tpox-benchmark.com/custacc\";
declare variable $id external;
for $cust in fn:collection()/c:Customer[@id=$id]
for $sec in fn:collection()/s:Security[s:Symbol=$cust/c:Accounts/c:Account/c:Holdings/c:Position/c:Symbol/fn:string(.)]
return <Security>{$sec/s:Name/text()}</Security>

providing a particular $id and iterate through expression tree. When I do evaluateVariable for one of VariableReferences NPE is thrown:

java.lang.NullPointerException: null
at net.sf.saxon.om.SequenceTool.toGroundedValue(SequenceTool.java:49) ~[Saxon-HE-9.7.0-4.jar:na]
at net.sf.saxon.expr.Assignation.evaluateVariable(Assignation.java:130) ~[Saxon-HE-9.7.0-4.jar:na]
..........

Please have a look.
Note: I just moved to Saxon 9.7. Earlier I use Saxon 9.5.1-8 and had no this NPE issue on the same query.

Thanks, Denis.

Related

Support Requests: #81

Discussion

  • Anonymous

    Anonymous - 2016-04-05

    Hi O'Neil,

    Thanks for the quick response.
    Yes, I'm aware about the new issue tracker, but haven't found how to submit a new issue there. Do I need to register in order to do so?

    Regarding the NPE: I use Saxon via its Java API. I have a custom CollectionFinder class. When Saxon run XQuery against collection(-s) I analyze expression tree and return back custom ResourceCollection which select documents dynamically from my external data store. So, the NPE happens even before I select any source document.

    A piece of code where NPE happens is:

        if (ex instanceof GeneralComparison10 || ex instanceof GeneralComparison20 || ex instanceof ValueComparison) {
            BinaryExpression be = (BinaryExpression) ex;
            Object value = null;
            String pName = null;
            for (Operand o: be.operands()) {
                Expression e = o.getChildExpression();
                if (e instanceof VariableReference) {
                    Binding bind = ((VariableReference) e).getBinding();
                    if (bind instanceof LetExpression) {
                        Expression e2 = ((LetExpression) bind).getSequence();
                        if (e2 instanceof Atomizer) {
                            e2 = ((Atomizer) e2).getBaseExpression();
                            if (e2 instanceof VariableReference) {
                                // paired ref to the e
                                pName = ((VariableReference) e2).getBinding().getVariableQName().getLocalPart(); 
                            }
                        }
                    }
    
                    if (pName == null) {
                        pName = bind.getVariableQName().getClarkName();
                    }
                    value = getValues(bind.evaluateVariable(ctx)); // NPE happens here!
                    break;
                } else if (e instanceof StringLiteral) {
                    value = ((StringLiteral) e).getStringValue();
                    break;
                } else if (e instanceof Literal) {
                    value = getValues(((Literal) e).getValue()); 
                    break;
                }
            }
    

    .........

    Thanks, Denis

     

Anonymous
Anonymous

Add attachments
Cancel