I have an XML, with multiple nodes
Have written query options with a parameter and save it to database
<search:options xmlns:search="http://marklogic.com/appservices/search">
<search:constraint name="extValue">
<search:value>
<search:element ns="urn:hl7-org:v2xml" name="CX.1" />
</search:value>
</search:constraint>
<search:extract-document-data xmlns="urn:hl7-org:v2xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v2xml ADT_A01.xsd">
<search:extract-path>/ADT_A01/PID/PID.3/CX.4/HD.1</search:extract-path>
<search:extract-path>/ADT_A01/PV1/PV1.7/XCN.2/FN.1</search:extract-path>
<search:extract-path>/ADT_A01/PV1/PV1.7/XCN.3</search:extract-path>
<search:extract-path>/ADT_A01/PV1/PV1.4/CWE.1</search:extract-path>
</search:extract-document-data>
</search:options>
retrieved results
DatabaseClient client = factory.getSuperMLConnection();
QueryManager queryMgr = client.newQueryManager();
//used the query options above which is saved to DB with name v2searchQueryOpts
StructuredQueryBuilder qb = new StructuredQueryBuilder("v2searchQueryOpts");
//this is one of the element value in the xml
StructuredQueryDefinition querydef =
qb.and(qb.valueConstraint("extValue", "1.32022.1.10.2"));
SearchHandle resultsHandle = queryMgr.search(querydef, new SearchHandle());
MatchDocumentSummary[] summaries = resultsHandle.getMatchResults();
// here is where i am concerned.
for (MatchDocumentSummary summary : summaries) {
ExtractedResult extracted = summary.getExtracted();
if (Format.XML == summary.getFormat()) {
Document facility = extracted.next().getAs(Document.class);
Document status = extracted.next().getAs(Document.class);
Document physicianFirstName = extracted.next().getAs(Document.class);
Document physicianLastName = extracted.next().getAs(Document.class);
System.out.println("status is :: " + status.getFirstChild().getTextContent());
System.out.println("facility is :: " + facility.getFirstChild().getTextContent());
System.out.println("physicianFirstName is :: " + physicianFirstName.getFirstChild().getTextContent());
System.out.println("physicianLastName is :: " + physicianLastName.getFirstChild().getTextContent());
}
}
}
The result from the database has extracted content as below
<search:extracted>
<HD.1 xmlns="urn:hl7-org:v2xml">ABC</HD.1>
<CWE.1 xmlns="urn:hl7-org:v2xml">E</CWE.1>
<FN.1 xmlns="urn:hl7-org:v2xml">Sri</FN.1>
<XCN.3 xmlns="urn:hl7-org:v2xml">N</XCN.3>
</search:extracted>
My objective is to retrieve and populate a java POJO. is there any other way i can directly map my result to POJO?