The matchCandidateWithSuspectsXML() 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 or match suspect. The “matchPattern” attribute will be set to the appropriate match pattern value. This method returns both matches and match suspects. To return only matches, use the matchCandidateXML method.
Syntax
public void matchCandidateWithSuspectsXML(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 will be returned. |
retCode |
int[ ] |
Out |
4 |
Error code that indicates the status of the method call. |
n* indicates that the length depends on the platform on which the program runs.
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 document
String rootTag = "CustomerData/PrimaryCustomer";
// This is the input (dirty) XML document
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 and initialize matcher server using openMatcherEx()
handle = testClient.openMatcherEx(systemID, serverName, retCode);
if (retCode[0] == 0) {
StringBuffer outputXML = new StringBuffer ("");
testClient.matchCandidateWithSuspectsXML(handle, rootTag, inputXML,
outputXML, retCode);
if (retCode[0] != 0) {
System.out.println("matchCandidateWithSuspectsXML method returned" +
retCode[0]);
} else {
// Process matched data in outputXML
}
// Close and release matcher server
testClient.closeMatcherEx(handle, retCode);
}