cancel
Showing results for 
Search instead for 
Did you mean: 

XSL Mapping

Former Member
0 Kudos

Hi,

I'm currently working in a scenario which involves XSLT mapping.Below is the source message structure:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:MT_SESSIONRESP xmlns:ns1="urn:horizon:sessionmgmt">

<SessionId/>

</ns1:MT_SESSIONRESP>

</ns0:Message1>

<Message2>

<upsert xmlns:ns2="urn:enterprise.soap.sforce.com">

<:externalIDFieldName/>

<ns2:sObjects>

<ns3:fieldsToNull xmlns:ns3="urn:sobject.enterprise.soap.sforce.com"/>

<ns3:Id xmlns:ns3="urn:sobject.enterprise.soap.sforce.com"/>

<b><ns3:Owner xmlns:ns3="urn:sobject.enterprise.soap.sforce.com">

<Horizon_user_id></Horizon_user_id>

<ns3:Owner></b>

</ns2:sObjects>

</ns2:upsert>

</ns0:Message2>

</ns0:Messages>

<u><b>Target Message Required:</b></u>

<?xml version="1.0" encoding="utf-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge" xmlns:ns1="urn:enterprise.soap.sforce.com" xmlns:ns2="urn:enterprise.soap.sforce.com">

<ns0:Message1>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Header>

<SessionHeader xmlns:ns1="urn:horizon:sessionmgmt" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">

<ns1:sessionId/>

</SessionHeader>

</soapenv:Header>

<soapenv:Body>

<upsert xmlns="urn:enterprise.soap.sforce.com">

<externalIDFieldName/>

<sObjects xsi:type="ns1:Account" xmlns:ns1="urn:sobject.enterprise.soap.sforce.com">

<ns3:fieldsToNull xmlns:ns3="urn:sobject.enterprise.soap.sforce.com"/>

<ns3:Id xmlns:ns3="urn:sobject.enterprise.soap.sforce.com"/>

<b> <ns3:Owner xmlns:ns3="urn:sobject.enterprise.soap.sforce.com">

<ns3:type xmlns:ns3="urn:sobject.partner.soap.sforce.com">User</ns3:type>

<Horizon_User_Id></Horizon_User_Id>

</ns3:Owner></b>

</sObjects>

</upsert>

</soapenv:Body>

</soapenv:Envelope>

</ns0:Message1>

</ns0:Messages>

In the target structure tag <type> is hardcoded and its a substructure to owner field.Guys help me with xslt mapping to obtain the above mentioned target structure from the source structure.

Regards

Jithesh

Accepted Solutions (0)

Answers (2)

Answers (2)

udo_martens
Active Contributor
0 Kudos

Hi Jithesh,

i see nothing taken from source. So you just write down, what you need, nothing else. If you want to read some source element values use

<xsl:value-of select="//mySourceField"/>

Regards,

Udo

Former Member
0 Kudos

Hi Udo,

Using

<b>xsl:copy-of select="/ns0:Messages/ns0:Message2/ns2:upsert/ns2:sObjects[.]/@*|node()"</b> statement i copied the entire fields of sObjects from the source to the target sObjects field.

But my question is how to traverse through the target structure and add a field named type(<type></type> ) below the owner tag.The structure required is

<b><sObjects>

.

.

.

.

<Owner>

<type></type>

</owner>

.

.

.

</sObjects></b>

Regards

Jithesh

udo_martens
Active Contributor
0 Kudos

Hi Jithesh,

as i told you. Just write target elements down you need. If you want to take values from source, use "value-of". "Copy-of" can only copy parts, never change. Some manuell work.

May be its easier if you use a not parsing mapping kind, like Java or ABAP, where just replace a substring.

Regards,

Udo

Former Member
0 Kudos

Hi Udo,

Tanx for ur quick response.I can do it manually using <value-of> but if i have large number of fields in source , then creating each field in target structure manually will become difficult.So Is there any other way to implement it?

Regards

Jithesh

Former Member
0 Kudos

Hi,

Try to create target structure and export the xsd into Altova mapforce change according to your requirement..

After that In Altova mapforce you can have source and target structure import and do the mapping , click on xlst , then the xslt file will be generated later, create zip and iport under archieve , in Interface mapping select the XSLT and select imported xslt mapping program..

I hope you got it..

see for XSLT help..

XSLT Mapping

/people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping

/people/sreekanth.babu2/blog/2005/01/05/design-time-value-mappings-in-xslt

/people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping

XSLT Mapping with java enhancement

/people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners

Regards

Chilla..