Session session = new Session("localhost", 1984, "admin", "admin");
//Define a query and create a query object
String q = "declare variable $name external; for $i in 1 to 10 return element { $name } { $i }"
Query query = session.query(q);
//Call the bind method of your query object
query.bind("$name", "Number");
//Call the init method of your query object
print query.init();
//Iterate through the query object
while(query.more()) print query.next();
//Close your query object:
print query.close();
</pre>