Good afternoon,
I have a QueryProcessor to grab the top level items which works, but
then I want to iterate over these items to query sub-items. My XML is
currently (sub-section, excuse any typos however it is well formed)
<MappingRequest>
<Mappings destination="invoice_sftp" map="pdf_invoice">
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/invoice/2/3/1/231749.pdf"
xpath="//CommercialDocument[@id='231749']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/invoice/2/3/1/231750.pdf"
xpath="//CommercialDocument[@id='231750']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/invoice/2/3/1/231751.pdf"
xpath="//CommercialDocument[@id='231751']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/invoice/2/3/1/231752.pdf"
xpath="//CommercialDocument[@id='231752']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/invoice/2/3/1/231753.pdf"
xpath="//CommercialDocument[@id='231753']"/>
</Mappings>
<Mappings destination="invoice_sftp" map="pdf_device_report">
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/report/8/3/7/8375680.pdf"
xpath="//Device[@report_id='8375680']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/report/8/3/7/8375681.pdf"
xpath="//Device[@report_id='8375681']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/report/8/3/7/8375679.pdf"
xpath="//Device[@report_id='8375679']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/report/8/3/7/8375682.pdf"
xpath="//Device[@report_id='8375682']"/>
<Mapping
path="/var/lib/michrosatbilling/billingrunoutput_testing/dummy/report/8/3/7/8375686.pdf"
xpath="//Device[@report_id='8375686']"/>
</Mappings>
</MappingRequest>
My code in brief is:
final Context context = new Context();
new CreateDB("LocalDB", "/test.xml").execute(context);
QueryProcessor proc = new QueryProcessor("/MappingRequest/Mappings",
context);
// Loop over the mappings, get the map name then iterate over the
underlying mapping nodes
for(Item item; (item = iter.next()) != null;) {
Object elem = BXNode.get((ANode)item);
BXElem node1 = (BXElem)elem;
System.out.println(node1.getAttribute("map"));
QueryProcessor proc2 = proc.context(item);
proc2.??("/Mapping");
Iter iter2 = proc.iter();
for(Item item2; (item2 = iter2.next()) != null;) {
elem = BXNode.get((ANode)item2);
node1 = (BXElem)elem;
System.out.println(node1.getNodeName());
}
}
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? Feel I'm almost there with various ideas but nothing seems
to change the context to the an item, rather than sticking with the
originally loaded document.
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.
Kind regards
Chris Speare
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.