cancel
Showing results for 
Search instead for 
Did you mean: 

XML to string in XSL mapping

Former Member
0 Kudos

Hi All,
Im trying to achieve the following transformation by using XSL mapping:

Input
<ROOTNODE>
<NODEPARAMETERS>
<USER>ABC</USER>
<PASSWORD>DEF</PASSWORD>
<REQUESTID>12321</REQUESTID>
</NODEPARAMETERS>
<NODEMESSAGE>
<DESTINATION>453453453</DESTINATION>
<TEXT>TESTING</TEXT>
<SOURCE>31232</SOURCE>
</NODEMESSAGE>
</ROOTNODE>

Output
USER=ABC&PASSWORD=DEF&REQUESTID=12321
<NODEMESSAGE>
<DESTINATION>453453453</DESTINATION>
<TEXT>TESTING</TEXT>
<SOURCE>31232</SOURCE>
</NODEMESSAGE>

Basically, im trying to output the node parameters as string and node message as XML in a single output.
Is this possible via XSL mapping?
If so, how is it done?

Regards,
J

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi all,
In my source XML, i have 2 nodes as follows:
<ROOTNODE>
   <NODEPARAMETERS>
      <USER>ABC</USER>
      <PASSWORD>DEF</PASSWORD>
      <REQUESTID>12321</REQUESTID>
   </NODEPARAMETERS>
   <NODEMESSAGE>
      <DESTINATION>453453453</DESTINATION>
      <TEXT>TESTING</TEXT>
      <SOURCE>31232</SOURCE>
   </NODEMESSAGE>
</ROOTNODE>

For the target, im expecting that the Nodeparameters should appear as text/string without <> tags, and concatenated by & character; followed by the node message to appear as xml
so ideally the output should be somewhat like this:

USER=ABC&PASSWORD=DEF&REQUESTID=12321
<NODEMESSAGE>
<DESTINATION>453453453</DESTINATION>
<TEXT>TESTING</TEXT>
<SOURCE>31232</SOURCE>
</NODEMESSAGE>

Is this possible through XSL mapping/ Java mapping? or a combination of both?
Any pointers to the java code?
I assume i can have both XSL and java mapping in the operation mapping....
Regards,
J

RaghuVamseedhar
Active Contributor
0 Kudos

Janan,

Please use Java Mapping. Please follow example shown in How to create Java Mapping in SAP PI / PO

add this logic to get user name and password from input content.

input.substring(input.indexOf("<USER>")+6, input.indexOf("</USER>"))

input.substring(input.indexOf("<PASSWORD>")+10, input.indexOf("</PASSWORD>"))

iaki_vila
Active Contributor
0 Kudos

Hi Janan,

Yes it's possible, Check the point 4 in this document

Regards.

Former Member
0 Kudos

Hi Inaki,

I have seen that link.

But <xsl:copy-of> function allows to copy the xml. But i also need to output the top part as a string, with no xml tags.

Hope i am making sense.

Regards,

J

iaki_vila
Active Contributor
0 Kudos

Hi Janan,

Please share a complete example with the source and target XML. We will help you easier in this way.

Regards.

RaghuVamseedhar
Active Contributor
0 Kudos

Janan,

XSLT can output text or XML or html. Not combinations.

Please use Java mapping.

http://www.w3schools.com/xsl/el_output.asp