cancel
Showing results for 
Search instead for 
Did you mean: 

Sample XSLT mapping required

Former Member
0 Kudos

Hi,

I have a requirement where I want to transform the incoming XML from one structure to another (basically dropping the namespaces/prefixes etc but keeping the structure) and have reached the conclusion this can be achieved using an XSLT mapping.

Hoowever, can you please point me in the irection of some good websites that have good XSLT examples and code snippets ?

Thanks

Colin.

Accepted Solutions (1)

Accepted Solutions (1)

prasanthi_chavala
Active Contributor
0 Kudos

Hi Colin,

I have done some simple scenario regarding this XSLT mapping.This is the simple piece of code tat i have executed.Hope it will be helpful to you.And refetr to w3schools.com for more info.

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<MT_EMP_TARGET>

<xsl:for-each select="//EMP_DATA">

<EMP_DATA>

<xsl:variable name="fname" select="//EMP_DATA/First_Name"/>

<xsl:variable name="lname" select="//EMP_DATA/Last_Name"/>

<Emp_Code><xsl:value-of select="//EMP_DATA/Emp_Code"/></Emp_Code>

<Name><xsl:value-of select="concat($fname,' ',$lname)"/></Name>

<Join_Dt><xsl:value-of select="//EMP_DATA/Join_Dt"/></Join_Dt>

<Designation><xsl:value-of select="//EMP_DATA/Level"/></Designation>

<Dept><xsl:value-of select="//EMP_DATA/Dept"/></Dept>

</EMP_DATA>

</xsl:for-each>

</MT_EMP_TARGET>

</xsl:template>

</xsl:stylesheet>

And here is my input data:

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

<MT_EMP>

<EMP_DATA>

<Emp_Code>2994</Emp_Code>

<First_Name>Gary</First_Name>

<Last_Name>Moore</Last_Name>

<Join_Dt>02/21/05</Join_Dt>

<Dept>SAP</Dept>

<Level>P3</Level>

</EMP_DATA>

<EMP_DATA>

<Emp_Code>2995</Emp_Code>

<First_Name>Dolly</First_Name>

<Last_Name>Smith</Last_Name>

<Join_Dt>12/11/06</Join_Dt>

<Dept>CSD</Dept>

<Level>P4</Level>

</EMP_DATA>

<EMP_DATA>

<Emp_Code>2996</Emp_Code>

<First_Name>Sam</First_Name>

<Last_Name>Brown</Last_Name>

<Join_Dt>04/01/05</Join_Dt>

<Dept>Java</Dept>

<Level>P3</Level>

</EMP_DATA>

<EMP_DATA>

<Emp_Code>2997</Emp_Code>

<First_Name>Kim</First_Name>

<Last_Name>Larson</Last_Name>

<Join_Dt>02/02/06</Join_Dt>

<Dept>SAP</Dept>

<Level>P3</Level>

</EMP_DATA>

</MT_EMP>

Cheers,

Prasanthi.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Please see the below links,

/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

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

Regards

Chilla..

former_member189354
Contributor
0 Kudos

Hi,

For XSLT mapping try to use Third pary mapping tools like stylus, altova..Try to import the source and target message xsd's into tools. Try to map the fields more similar to our GMT. There will be options for generating the XSLT either in 1.0 or 2.0 Once completed. Try to import into XI IR. Tools also provide debugging of XSLT code which will provide good understanding of the code.

Regards,

Rao.M

Former Member
0 Kudos

you can have a look at Anish's file to idoc scenario used XSLT mapping.

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

for more you can have a look at :

http://www.w3.org/TR/xslt20/

thanks,

pooja

moorthy
Active Contributor
0 Kudos

Hi,

go thru this- good examples-

http://w3schools.com/xsl/default.asp

check out this thread also- with editors etc

rgds,

moorthy

Former Member
0 Kudos

go to http://www.w3schools.com/xsl/, you'll have simple and easy to understand examples