The matchCandidateXML() method is used to match a record in an XML document to candidate records embedded in the same XML document. This method will append the “matchPattern” attribute to any candidate record that is considered a match. The “matchPattern” attribute will be set to the appropriate match pattern value. This method does not return match suspects. To return match suspects as well as candidates, use the matchCandidateWithSuspectsXML() method on page 45.
Syntax
public void matchCandidateXML(int handle,
java.lang.String rootTag,
java.lang.String inputXML,
java.lang.StringBuffer outputXML,
int retCode[]);
Parameters
Name |
Type |
Use |
Length |
Description |
---|---|---|---|---|
handle |
int |
In |
–– |
Handle to a Director matcher server. |
rootTag |
string[ ] |
In |
n* |
XML root tag. |
inputXML |
string[ ] |
In |
n* |
XML string containing the data to be matched. |
outputXML |
string[ ] |
Out |
n* |
StringBuffer where the matched XML is returned. |
retCode |
int[ ] |
Out |
4 |
Error code that indicates the status of the method call. |
n* indicates maximum length and varies depending on the platform on which the program is run.
Example
TrilTGenClient testClient = new TrilTGenClient();
// Return code and handle
int[] retCode= new int[1];
int handle = 0;
// System and Server Id for attach()
char systemID = 'G';
String serverName = "RMatcher";
// Root Tag of XML doc
String rootTag = "CustomerData/PrimaryCustomer";
// This is the input (dirty) XML doc
String inputXML = "<?xml version = '1.0' encoding = 'ISO-8859-1' standalone =
'no'?>" +
"<CustomerData>" +
"<REQUESTTYPE>RMatch</REQUESTTYPE>" +
"<PrimaryCustomer>" +
"<Name>John Smith</Name>" +
"<Address>" +
"<StreetLine1>11 falk</StreetLine1>" +
"<StreetLine2 />" +
"<City>pompton lakes</City>" +
"<State>NJ</State>" +
"<Country>US</Country>" +
"<ZipCode></ZipCode>" +
"</Address>" +
"</PrimaryCustomer>" +
"<Candidate>" +
"<Name>J Smith</Name>" +
"<Address>" +
"<StreetLine1>10 falk</StreetLine1>" +
"<StreetLine2 />" +
"<City>pompton lakes</City>" +
"<State>NJ</State>" +
"<Country>US</Country>" +
"<ZipCode></ZipCode>" +
"</Address>" +
"</Candidate>" +
"<Candidate>" +
"<Name>Tom Romeo</Name>" +
"<Address>" +
"<StreetLine1>11 falk</StreetLine1>" +
"<StreetLine2 />" +
"<City>pompton lakes</City>" +
"<State>NJ</State>" +
"<Country>US</Country>" +
"<ZipCode></ZipCode>" +
"</Address>" +
"</Candidate>" +
"</CustomerData>;
// Attach to matcher server and initialize Matcher session
handle = testClient.openMatcherEx(systemID, serverName, retCode);
if (retCode[0] == 0) {
StringBuffer outputXML = new StringBuffer ("");
testClient.matchCandidateXML(handle, rootTag, inputXML, outputXML, retCode);
if (retCode[0] != 0) {
System.out.println("matchCandidateXML method returned" +
retCode[0]);
} else {
// Process matched data in outputXML
}
// Close and release matcher server
testClient.closeMatcherEx(handle, retCode);}