Hi All,
I am trying java mapping to concate two fields. Below is my code but I am getting error at line - String document_exit. Please help
Code -
public class conc extends AbstractTransformation {
public void transform(TransformationInput input, TransformationOutput output)
throws StreamTransformationException {
String RESULT = new String();
InputStream in = input.getInputPayload().getInputStream();
OutputStream out = output.getOutputPayload().getOutputStream();
try {
//Create DOM parser
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
NodeList n1 = doc.getElementsByTagName("Emp_Name");
NodeList n2 = doc.getElementsByTagName("Emp_Surname");
String nv1 = doc.getNodeName();
String nv2 = doc.getNodeName();
if (nv1.equals(n1) && nv2.equals(n2))
RESULT = nv1.concat(nv2);
String document_exit = "<?xml version="1.0" encoding="UTF-8"?>" +
"<ns0:MT_SJava_Concanat xmlns:ns0=urn:javaMapping.com/Rashmi>" +
"<Records> <EmployeeID/> <RESULT>" + RESULT + "</RESULT> </Records>";
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(doc), new StreamResult(document_exit));
}catch (Exception exception) {
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
BR,
Rashmi