Project

Profile

Help

Bug #5361 » SaxonMwe.java

MWE java class - Clément Fournier, 2022-02-27 17:17

 
import net.sf.saxon.Configuration;
import net.sf.saxon.expr.Expression;
import net.sf.saxon.expr.LocalVariableReference;
import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.sxpath.IndependentContext;
import net.sf.saxon.sxpath.XPathEvaluator;
import net.sf.saxon.sxpath.XPathExpression;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.value.BooleanValue;
import net.sf.saxon.value.SequenceType;

/**
* @author Clément Fournier
*/
public class SaxonMwe {

public static void main(String[] args) throws XPathException {
Configuration configuration = Configuration.newConfiguration();

IndependentContext staticCtx = new IndependentContext(configuration) {
{
declareVariable(null, "falseVar");
}

@Override
public Expression bindVariable(StructuredQName qName) throws XPathException {
LocalVariableReference local = (LocalVariableReference) super.bindVariable(qName);
if (qName.getLocalPart().equals("falseVar")) {
local.setStaticType(
SequenceType.SINGLE_BOOLEAN,
BooleanValue.FALSE,
0);
}
return local;
}
};

final XPathEvaluator xpathEvaluator = new XPathEvaluator(configuration);
xpathEvaluator.setStaticContext(staticCtx);

XPathExpression xpathExpression = xpathEvaluator.createExpression(
"//A[$falseVar=true()][child::*[2]]"
);


}

}
    (1-1/1)