cancel
Showing results for 
Search instead for 
Did you mean: 

XML Transformation using XSLT

Former Member
0 Kudos

Hi,

I have a scenario where I need to perform an XML to XML transformation and I need to do this using XSLT mapping.

I am using XMLSpy.

Could somebody help me on this issue?Any weblogs that can help me on this?

regards,

Prashanth

Accepted Solutions (1)

Accepted Solutions (1)

former_member8655
Active Participant
0 Kudos

hi Prashanth

for XSLT mapping u have to use mapforce a tool

available with xmlspy

u can a 30 days trial from altova.

Answers (7)

Answers (7)

bhavesh_kantilal
Active Contributor
0 Kudos

hi prashanth,

In your Altova XMLSpy, after u've typed your XSL program which will be performing the XSLT mapping, just select the Menu --> XSL/XQuery, and then --> XSDTransformation (f10 will also do..!!). It will ask u to give the path for your source XML file and generate the output structure on the basis of the code u've typed.

Regards,

Bhavesh

former_member8655
Active Participant
0 Kudos

Hi prashanth

ther are few forum links for XSLT mapping go throgh it

and do reward with points if useful

Enjoy!!

Mitesh

Former Member
0 Kudos

Hi Divya,

I do not want to get into XI to solve this problem. I have shown the source and target XML in my previous post.

Is there a way I can write the xslt in XMLSpy without using XI?

Former Member
0 Kudos

Hi Prashanth,

You can do the xsl transformation in XMLSpy itself.First create your source xml file in XMLSpy by selecting file type as xml.After that create your xslt program file by selecting file type as xslt.

Then you can use the xslt program for transformation of source xml into target xml by choosing menu XSL/XQuery->XSL Transformation.

sample xsl code for an example:

source xml structure:

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

<root>

<header>

<detail>

Detail1

</detail>

<detail>

Detail2

</detail>

</header>

<header>

<detail>

Detail3

</detail>

</header>

</root>

-


xsl program:

<xsl:stylesheet version = '1.0'

xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="/">

<root>

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

<idoc>

<xsl:for-each select="detail">

<detail>

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

</detail>

</xsl:for-each>

</idoc>

</xsl:for-each>

</root>

</xsl:template>

</xsl:stylesheet>

-


target xml structure:

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

<root>

<idoc>

<detail>

Detail1

</detail>

<detail>

Detail2

</detail>

</idoc>

<idoc>

<detail>

Detail3

</detail>

</idoc>

</root>

Hope this would help.

Rgds

Sudhakar.

Former Member
0 Kudos

Hi Shailesh,

See..just imagine that I do not have access to XI. I have only the source and target XML and the XMLspy. How do I go about impementing the mapping in XSLT?

cheers,

Prashanth

Former Member
0 Kudos

Hi prashanth

XMLspy also give provisions to genarate XSDs. But u need to include the Namespaces in which u are working within XI in XSD.

i havent tried it. just give a try...

Cheers:)

Shailesh

Former Member
0 Kudos

Hi Sailesh,

Consider that I do not have the xsd, but only the XML structure. It is like this..

Src: <root>

<header> (1 to n occurances)

<detail>(1 to n occurances)

</detail>

</header>

Tgt: <root>

<idoc> (1 to n occurances)

<detail>(1 to n occurances)

</detail>

</idoc>

It is a multiple mapping scenario and I have to use only XSL mapping.

Former Member
0 Kudos

Hi prashanth

u have the XML structure for both Source and Target as well right.

Create <b>Data types</b> and <b>Message types</b> for both these structures within XI.

Now when u create the message type, u click on the TAB named <b>XSD</b>. Xsd will be generated for the Message type by XI itself.

Copy it and save it in a notepad with extension<b> .xsd</b>.

import this file in XMLspy and do the mapping..

Cheers:)

Shailesh

Former Member
0 Kudos

Hi,

First you construct ur data types both for source and target.In the interface mapping specify ur XSl mapping program.Note tht you dont need a message mapping here.

refer the pdf:

XSLT mapping in XI

regards

Priyanka

Former Member
0 Kudos

Hi prashant,

when u create a data type in XI, the xsd gets automatically generated in the tab next to the structure.. So u can use this to do your mapping :)best of luck.

Cheers,

Divya

Former Member
0 Kudos

Hi Prashanth

what u have to do is.

1) Take the xsd of ur Message types from Xi (both source and target).

2) load the same in XMLspy

3) Perform the mapping. Save the mapping program as <b>.xsl</b> extension.

4) Zip it and import it into <b>Imported archives</b> within XI.

5) while creating Interface mapping u can specify this as ur mapping program.

Cheers:)

Shailesh

Former Member
0 Kudos

Hi Prahsanth,

this blog may be of some help:

 

Priyanka