public static void examplePipeline() throws XPathException {
final Configuration config = new Configuration();
// Compile the first query
final StaticQueryContext sqc1 = config.newStaticQueryContext();
final XQueryExpression exp1 = sqc1.compileQuery("declare variable $in as xs:integer external;" +
"document{ <a>{$in * $in}</a> }");
// Compile the second query (each query should have its own static context)
final StaticQueryContext sqc2 = config.newStaticQueryContext();
final XQueryExpression exp2 = sqc2.compileQuery("/a + 5");
// Run the first query
final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
dynamicContext.setParameter("in", new Long(3));
final NodeInfo doc = (NodeInfo)exp1.evaluateSingle(dynamicContext);
// Run the second query
dynamicContext.clearParameters();
dynamicContext.setContextItem(doc);
final Object result = exp2.evaluateSingle(dynamicContext);
System.out.println("3*3 + 5 = " + result);
// The result is actually a java.lang.Double
}