on 07-31-2015 1:43 PM
Hi Experts,
I have one requirement. I have one Idoc to xml scenario in message mapping. The requirement is the target xml contains some nodes along with their type names.
For example
<ABC>
<XYZ xsi:type="ase:ABCDEF">
<EFG>
<PQR xsi:type="ase:DDFGY">
<MNBV>333</MNBV>
<JHGF>666</BGFD>
</PQR>
</EFG>
</XYZ>
</ABC>
Presently I can only create the xml along with the nodes, but the xsi:type is not getting created.
I need to include the types to the nodes <XYZ> and <PQR> by xslt mapping.
Can you please suggest how can i include the typenames beside the required nodes?
Thanks & Regards,
Treya
Thanks a lot for all of your suggestions. They were really helpful. Specially the solution provided by Nabendu helped me solve my problem.
Regards,
Treya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Treya,
<XYZ xsi:type="ase:ABCDEF">
This is not well-formed XML. Element/Attribute names can not have :. GraphicalMapping/XSLT can not create not well-formed XML.
You can create graphical mapping for <XYZ xsi__type="ase:ABCDEF">
Then use Java Mapping (after graphical map) to replace xsi__type with xsi:type
package javaapplication1;
import java.io.*;
import com.sap.aii.mapping.api.*;
public class NewClass1 {
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
try {
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
// Copy Input content to Output content
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
String input = new String(b);
input = input.replaceAll("xsi__type", "xsi:type");
outputstream.write(input.getBytes());
} catch (Exception exception) {
throw new StreamTransformationException(exception.toString());
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please check:
http://stackoverflow.com/questions/17129343/how-to-add-xsi-type-value-namespace
Regards,
Nabendu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Treya,
instead of going to XSLT mapping, i can suggest you to go for Graphical only..and try to create structure for target as what ever fields you want to send type name, create structure as same like that.
all you have to do is just add an argument for particular fields while you create data type.
and make sure argument name would be type
then in mapping level you just map with constant or map with source filed if u are getting type from source structure,
i hope this is easy way to develop.
let me know if u stuck.
BR,
Maheswarareddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.