on 07-25-2011 4:25 PM
Hi Experts,
I want to put xml into string and i need to change lessthan symbol to "<" and greaterthan symbol to ">" , can anyone please help me how to do this??? can you provide code for java mapping or XSLT mapping to achive this.
SOURCE
<?xml version="1.0" encoding="UTF-8"?>
<ns0:source_mt xmlns:ns0="urn:ppp:prototype">
<row>
<name1>IT</name1>
<name2>SOLUTIONS</name2>
</row>
</ns0:source_mt>
TARGET
<?xml version="1.0" encoding="UTF-8"?>
<ns0:target_mt xmlns:ns0="urn:ppp:prototype">
<row>
<Body>"<"name1">" IT"<"/name1">" "<"name2">" SOLUTIONS"<";/name2">" </Body>
</row>
</ns0:target_mt>
Hi ,
here is the XSLT code to obtain the desired output
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<ns0:target_mt xmlns:ns0="urn:ppp:prototype">
<xsl:for-each select="//row">
<row>
<Body>
<xsl:for-each select="name1">
<xsl:value-of select="concat('*"<"name1">"*',normalize-space(.),'*"<"/name1">"*')"></xsl:value-of>
</xsl:for-each>
<xsl:for-each select="name2">
<xsl:value-of select="concat('*"<"name2">"*',normalize-space(.),'*"<"/name2">"*')"></xsl:value-of>
</xsl:for-each>
</Body>
</row>
</xsl:for-each>
</ns0:target_mt>
</xsl:template>
</xsl:stylesheet>
output produced as viewed in browser is
http://postimage.org/image/1lqbgw8kk/
Now to obtain exactly the output you posted earlier here is the code
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<ns0:target_mt xmlns:ns0="urn:ppp:prototype">
<xsl:for-each select="//row">
<row>
<Body>
<xsl:for-each select="name1">
<xsl:value-of select="concat('*"&lt"name1"&gt"*',normalize-space(.),'*"&lt"/name1"&gt"*')"></xsl:value-of>
</xsl:for-each>
<xsl:for-each select="name2">
<xsl:value-of select="concat('*"&lt"name2"&gt"*',normalize-space(.),'*"&lt"/name2"&gt"*')"></xsl:value-of>
</xsl:for-each>
</Body>
</row>
</xsl:for-each>
</ns0:target_mt>
</xsl:template>
</xsl:stylesheet>
output you can see from link below
http://postimage.org/image/2c7bzo478
Hope this helps.
Hi,
Could you please kindly let us know if the solution is working properly as per your requirement?
regards
Anupam
Edited by: anupamsap on Jul 26, 2011 6:29 AM
Edited by: anupamsap on Jul 26, 2011 4:10 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use - http://wiki.sdn.sap.com/wiki/display/XI/WholePayloadtoaXML+field
in the java code, just put a replaceAll java method to chance the < to lt and > to gt.
ex;
payload = payload.replaceAll("<", "<");
payload = payload.replaceAll(">", ">");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you seen this link?
/people/jyothi.anagani/blog/2010/06/17/convert-the-input-xml-to-string-in-pi-71-using-standard-graphical-mapping
Use Return as XML option in the mapping to achieve this. I believe you use PI 7.1 and above.
If your version is below 7.1 then use
http://wiki.sdn.sap.com/wiki/display/XI/JavaMapping-ConverttheInputxmlto+String
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.