Anda di halaman 1dari 7

Adding Carriage Return or Line Feed IN xml

FILE using JAVA Mapping through Command

Problem Statements:
Adding Carriage Return or Line Feed after tag.
This problem can be solved by using XSLT and Java Mapping I am here define only through .
JAVA Mapping:
Here I take example of customer balance interface which Proxy to file scenario. And I am not using
any java base tool like Eclipse for java or Netweaver Developer Studio. I am using simple java
commands using command prompt to execute java file and creating jar file.This blog also explain
basics of java mapping.
1. For Java Mapping first we need aii_map_api.jar jar files that can find from various ways
You can check below Wiki for that:
I used the last option define there
Copy files from the local cache directory:
File name: RMaii_map_api.jar
You can rename that file to: aii_map_api.jar

I create a file named: with following code.

A simple code is written in java for add Carriage Return or Line Feed after tags.

import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.OutputKeys;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class AddCRorLF implements StreamTransformation{
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(in);

TransformerFactory tFactory = TransformerFactory.newInstance();

Transformer t = tFactory.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.transform(new DOMSource(doc), new StreamResult(out));
catch(Exception e)
throw new StreamTransformationException("Error During Mapping", e);
public void setParameter(Map arg0) {

A time to compile the file.

Put both files in one folder as below:


Cd d:\gagan
Javac classpath aii_map_api.jar
After that class file will created.
Then use following command for creating jar file:
Jar cvf AddCRorLF.jar AddCRorLF.class

Then you can see following file in the folder:

Go to Repository part and I have created following Message mapping for Customer

Right click on imported archive and create new.

Give the name and click on create.

Click on import archive and then select AddCRorLF.jar then open.

Following files are uploaded.

Then Save And Activate.

Then Go to Interface Mapping that I have all ready created.

Earlier it is showing like that at test tab all result is coming in one line:

Now add our java mapping after message mapping.

Select our Class

You can see following java mapping added after message mapping

In Test tab.