Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
The problem is, the REST service requires that the passed XML file has a new line after each tag (I think people call that pretty XML)
<task>
<job>JOB_NAME</job>
</tasks>
I am not sure if there exists API used to generate a pretty document.
If exists, you can create a routine and call the routine to transform it after the document is generated with tXMLMap.
The method parse(Document) in type PrettyXMLParsing is not applicable for the arguments (Document)
output_row.body = new PrettyXMLParsing().parse(input_row.body);
package routines;
import java.io.FileInputStream;
import java.io.StringWriter;
import java.io.Writer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
public class PrettyXMLParsing {
public Document parse(Document xml) throws Exception {
Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
tf.setOutputProperty(OutputKeys.INDENT, "yes");
Writer out = new StringWriter();
tf.transform(new DOMSource(xml), new StreamResult(out));
System.out.print( out.toString());
return convertStringToDoc(out.toString());
}//parse
private Document convertStringToDoc(String fileContentStr){
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
DocumentBuilder db = dbf.newDocumentBuilder();
Document outputDoc = db.parse(new FileInputStream(fileContentStr));
return outputDoc;
}catch(Exception e){
e.printStackTrace();
}
return null;
}//convertStringToDoc
}//PrettyXMLParsing
output_row.body = new PrettyXMLParsing().parse(input_row.body);
output_row.body=PrettyXMLParsing.parse(input_row.body);