on 07-07-2009 8:24 AM
Hi
I have a requirement where i need to map incoming XML message (containing 20 filelds) into one field on target side..
Source message TargetMessage
<User> <Code Number>
<Name> <UserXML>
<Address>
<Street no>
.......
So entire User xml will goes to one field UserXML on tagert side... how can we do that..
PLease help on this
Regards,
Deeps
I had a similar requirement, this blog did the trick
/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
hope it helps u out
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your replies..
I have done XSLT mapping for converting the XML into string.. its wokring fine..
But i have problem source message is as shown below..
<Msg1>
<Number>
<Users>
<user>.....</user></Users>
</Msg1>
Target Message
<Msg2>
<Number>
<StringUsers>
</Msg>
So Number should goes to Number in target structure
and <Users> should goes to <Stringusers>
For User conversion i have done for XSLT mapping using above mentioned replies and its working fine..
How about NUmber Mapping.. i not able to do map in XSLT and Users
this is code i'm using for User xml Conversion.. i need to embedd code also for Number mapping
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<mt_Msg>
<Users>
<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>]]]]></xsl:text>
<xsl:copy-of select="*"/>
<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
</Users>
</mt_Msg>
PLease suggest
Regards
Sans
</xsl:template>
</xsl:stylesheet>
Thanks for your replies..
I have done XSLT mapping for converting the XML into string.. its wokring fine..
But i have problem source message is as shown below..
<Msg1>
<Number>
<Users>
<user>.....</user></Users>
</Msg1>
Target Message
<Msg2>
<Number>
<StringUsers>
</Msg>
So Number should goes to Number in target structure
and <Users> should goes to <Stringusers>
For User conversion i have done for XSLT mapping using above mentioned replies and its working fine..
How about NUmber Mapping.. i not able to do map in XSLT and Users
this is code i'm using for User xml Conversion.. i need to embedd code also for Number mapping
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<mt_Msg>
<Users>
<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>]]]]></xsl:text>
<xsl:copy-of select="*"/>
<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
</Users>
</mt_Msg>
</xsl:template>
</xsl:Stylesheet>
PLease suggest
Regards
Sans
Source:
<Msg1>
<Number>
<Users>
<user>.....</user></Users>
</Msg1>
Target:
<Msg2>
<Number>
<StringUsers>
</Msg>
For User conversion i have done for XSLT mapping using above mentioned replies and its working fine
Are you sure that the XSLT mapping which you mentioned is working for the above mentioned source and target structures?
I hope you have not jumbled your Source and target structures while posting.....
If the structures are correct then your XSLT mapping should not work
You need to include the XSLT logic within the target nodes (your XSLT mapping is under source Users node)...it should be under StringUsers node of the target structure....
Check and Confirm...
Regards,
Abhishek.
Abhishek you are Correct..
i have copied wrong code.. .. that should be under StringUser
So now what could be the code that i need to include in the XSLT the mapping for below output
<Msg2>
<Number>xx</Number>
<StirngUsers><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<Users>
<User>
.......
</User>
</Users>
]]>
</StringUsers>
</Msg2>
Regards,
Deeps
To include the entire Users XML portion of the Source into the StringUsers node of the target use the same XSLT logic...just some modifications:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<MT_TARGET>
<StringUsers>
<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>]]
]>
//if you use " * " then entire source structure will go into target StringUsers node]]>
Also do you need to pass the xml version statement to the target node?...if no then remove the reference from the above XSLT code....
@Nipun ~ graphical mapping wont work when your req is to send the XML into a target node......for this you need to take help of either JAVA or XSLT....
Regards,
Abhishek.
Thank you very much.. Abhishek... for you Reply...
I have done mapping with your code.. output is as shown below..
<Msg2>
<StirngUsers><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<Number>xx</Number>
<Users>
<User>
.......
</User>
</Users>
]]>
</StringUsers>
</Msg2>
instead of..
<Msg2>
<Number>xx</Number>
<StirngUsers><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<Users>
<User>
.......
</User>
</Users>
]]>
</StringUsers>
</Msg2>
i want the NUMBER value should be first value in the output
PLease suggest me on thiss
Regards,
Deeps
it seems that you are using " * " in the XSLT code in the xsl:copy-of select node, hence the even the Number is getting into StringUsers....instead give the XPATH value of the source Users node (alongwith the prefix ns0/ ns1.....as it is for the source MT).......looking at your mapping you also need to do the mapping between source and target Number nodes
The XSLT code given will only give XML in the StringUsers node and nothing else
To map Number node....click on the source Number node and without releasing drag the line till the target Number node...mapping will be done and you will get the Number node before thet target StringUsers node....
or add below statement befor the StringsUsers node..
<TargetNumber>
<xsl:value-of select="path of the SourceNumber node"/>
</TargetNumber>
Just dont forget to update the XSLT mapping with the XPATH of the source Users node..
Regards,
Abhishek.
Edited by: abhishek salvi on Jul 16, 2009 4:34 PM
Thanks for your Quick response.. Abhishek..
I Have done as per your suggestions... i included the XPATH for source node in <xsl:copy-of select "
But i'm getting some error while i'm testing..
<ns0:Msg2/StringUsers/Users"/> this was included in the Copy Of select syntax..
PLease Suggest on this..
Regards,
Deeps.
<ns0:Msg2/StringUsers/Users"/> this was included in the Copy Of select syntax..
This should not be the way.
1) Check the very first line of your XSLT mapping and determine which prefix is used for source and which one for target. Normally (not necessarily) it will be ns0 for source namespace and ns1 for target namespace.
2) Suppose your Source message is:
<MT_SOURCE>
<Data>
<Number>
<Users>
</Data>
</MT_SOURCE>
Target Message is:
<MT_TARGET>
<TargetNumber>
<StringUsers>
</MT_TARGET>
So now your entire XSLT will look like:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="TargetMessageNamespace" xmlns:ns0="SourceMessageNamespace">
<xsl:template match="/">
<ns1:MT_TARGET>
<ns1:TargetNumber>
<xsl:value-of select="ns0:MT_SOURCE/Data/Number"/>
</ns1:TargetNumber>
<ns1:StringUsers>
<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>]]
]>
]]>
Make sure that you understand why/ where i have included the prefixes (ns0, ns1), what are the fields of the source, target that are used and how they are used....just focus on the source and target structures which i have mentioned above and how the fields are then referred in the XSLT
What's wrong with Graphical mapping, you can use a concatenation function and can join multiple rows! Why do you specially require XSLT mapping ?
I do not find a perfect case situation for your need of XSLT mappings.
-Nipun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is there any conditions involved?
If yes then you an use it through UDF.
Else if it's direct (1-1) mapping and your target is 0-Unbounded then u can replicate the field and map.
Thanks
Ashmi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Please see this link
https://wiki.sdn.sap.com/wiki/display/XI/WholePayloadtoaXML+field
Regards,
Shweta.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use XML_to_String conversion:
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/javaMapping-ConverttheInputxmltoString
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try using this XSLT mapping:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<GetCustomerInformationResponse>
<GetCustomerInformationResult>
<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]></xsl:text>
<xsl:copy-of select="*"/>
<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
</GetCustomerInformationResult>
</GetCustomerInformationResponse>
</xsl:template>
</xsl:stylesheet>
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.