Hi Chris,
> Having worked with Saxon previously I was able to pass the XdmItem from
> one query to the context of another query - allowing further queries to
> be carried out, therefore I assumed I would be able to something similar
> with BaseX?
Here are two ways to do so:
QueryProcessor proc1 = new QueryProcessor("/MappingRequest/Mappings", context);Iter iter1 = proc1.iter();for(Item item1; (item1 = iter1.next()) != null;) {QueryProcessor proc2 = new QueryProcessor("Mapping", context);proc2.context(item1);Iter iter2 = proc2.iter();for(Item item2; (item2 = iter2.next()) != null;) {System.out.println(((ANode) item2).qname());}}
More compact (but may be less efficient if you do not want to process all results):
QueryProcessor proc1 = new QueryProcessor("/MappingRequest/Mappings", context);for(Item item1 : proc1.value()) {for(Item item2 : new QueryProcessor("Mapping", context).context(item1).value()) {System.out.println(item2.serialize());}}
> Secondly to this I need to workout how to perform the queries via a
> ClientSession - however that only seems to return a ClientQuery where
> .next() returns a String, rather than a workable Item or other object.
True; the solution above does not work with the client/server architecture. In that case, you’ll need to resort to XQJ or – which is what we usually do – do as much as possible in XQuery itself
Cheers,Christian
The information contained in the email and any files transmitted with it is confidential and intended for the addressee only. If you have received this email in error please accept our apologies and notify the originator. Any disclosure,
copying, distribution or any other use of this communication is strictly prohibited and may be unlawful. We reserve the right to monitor and intercept communications for lawful business purposes.
Wireless Innovation Ltd , Unit D2, Churcham Business Park, Churcham, Gloucestershire, GL2 8AX, Great Britain.
Company Registration Number 5240202, Place of Registration Companies House Cardiff.