on 07-10-2014 9:07 PM
Hi Guys,
I have a question on how to do it and any sample code/help will be appreciated.
I have seen a couple of threads related to this but doesnt seem to quite link up with my scenario :
I am using a xsd given by 3rd party but they also want the target payload xml to look like this :
<?xml version="1.0" encoding="utf-8"?>
<ABC xmlns="http://www.test1.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
.
.
.
.</ABC>
My PI maiing is producing the xml as following :
<?xml version="1.0" encoding="UTF-8"?>
<ns1:ABC xmlns="http://www.test1.com">
.
.
.
</ns1:ABC>
Any suggestion and help on how to acheive the 3rd party xml payload i.e. stripp of ns1 tags and insert xmlns:xsi="http://www.w3.org/2001/XMLSchema namepspace at root level along with the target namespace.
thanks in advacne.
Did this by deploying JAVA mapping after Message mapping.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can use one to one message mapping. and use the below code in Init function of message mapping.
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException {
try {
String sourcexml = ""; String targetxml =""; String line ="";
InputStream ins = in.getInputPayload().getInputStream();
BufferedReader br = new BufferedReader( new InputStreamReader(ins));
while ((line = br.readLine()) != null)
sourcexml +=line;//+"\n";
br.close();
targetxml =sourcexml;
targetxml = targetxml.replaceAll("ns0", "");
out.getOutputPayload().getOutputStream().write(targetxml.getBytes());
} catch (Exception e) { throw new StreamTransformationException(e.getMessage()); }
}
public String concate(String str1, String str2, Container container) throws StreamTransformationException{
//String output = null;
return (str1+str2);
}
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.