cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting number inside the tags

Former Member
0 Kudos

Hi Frnds

My I/P payload is

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

<ns0:MPRDataExport_CRM_CEZH_REC_MT xmlns:ns0="ness.com:MPRDataExport_CRM_CEZH">

<item>

<CalYearMonth>201201</CalYearMonth01>

<TotalRevenus01>592421.60</TotalRevenus01>

i want the O/P as

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

<ns0:MPRDataExport_CRM_CEZH_REC_MT xmlns:ns0="ness.com:MPRDataExport_CRM_CEZH">

<item>

<CalYearMonth01>201201</CalYearMonth01>

<CalYearMonth02>201201</CalYearMonth01>

<CalYearMonth03>201201</CalYearMonth01>

.

.

.

<CalYearMonth26>201201</CalYearMonth01>

<TotalRevenus01>592421.60</TotalRevenus01>

<TotalRevenus02>592421.60</TotalRevenus01>

<TotalRevenus03>592421.60</TotalRevenus01>

.

.

.

<TotalRevenus26>592421.60</TotalRevenus01>

I am using graphical mapping. i want to inserts numbers inside the tag in the o/p xml file.I am not aware of xslt mapping. Pls tell me how to reach this requirement.

Thanks

Vankadoath

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Vankadoath.N ,

You can do this requirement with Java Mapping.

where you can create a dynamic loop , to create the output like below.

for(int i=1;i<=26;i++)

output = output + "<CalYearMonth" + i + ">" + data + "</CalYearMonth" + i + ">";

The same thing can be done for all the other tags in one loop.

for i values below 10 you can format it to have 2 digits.

Or if 26 is constant, then you can manually also create a XSD to have the tags, and populate using Message mapping.

Regards,

Srivatsan

Former Member
0 Kudos

HI Srivatsan thanks for your reply

I never used java or xslt mapping because i dont know java.

can you please tell me whats is the procedure for java mapping and how to include the code.

Thanks

Vankadoath

Former Member
0 Kudos

Hi,

For XSLT mapping in PI7.1 refer this:

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/soa-middleware/proc...

Ur xslt will be something like this(alter it according to ur req):

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

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

<xsl:template match="/">

<ns0:MPRDataExport_CRM_CEZH_REC_MT >

<item>

<xsl:call-template name="Increment">

<xsl:with-param name="i">1</xsl:with-param>

<xsl:with-param name="count" select="26"/>

</xsl:call-template>

</item>

</ns0:MPRDataExport_CRM_CEZH_REC_MT >

</xsl:template>

<xsl:template name="Increment">

<xsl:param name="i"/>

<xsl:param name="count"/>

<xsl:if test="$i &lt;= $count">

<xsl:variable name ="name" select="concat('CalYearMonth',$i)"/>

<xsl:element name="{$name}">

<xsl:value-of select="ns0:MPRDataExport_CRM_CEZH_REC_MT/item/CalYearMonth" />

</xsl:element>

</xsl:if>

<xsl:if test="$i &lt;=$count">

<xsl:call-template name="Increment">

<xsl:with-param name="i">

<xsl:value-of select="$i + 1" />

</xsl:with-param>

<xsl:with-param name="count">

<xsl:value-of select="$count"/>

</xsl:with-param>

</xsl:call-template>

</xsl:if>

</xsl:template>

</xsl:stylesheet>

Refer this for xslt basics:

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

Thanks

Amit

Former Member
0 Kudos

HI Amith Thanks for the reply. I gone through the blog and i installed Altova XMLSpy and we are using XI3.0

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/soa-middleware/proc...

from the blog I am not clear in the 4th page of the pdf. from the sender and receiver data types i can generate xsd files but not xsl style sheet.

My question is how to get the format of The XSL style sheet. and how to map the source and target structures in the Altova xml spy.

I am very new to xslt mapping. can you please tell me how to generate xslt code from the Altova XMLSpy.

Thanks

Vankadoath

Former Member
0 Kudos

Hi,

Open a notepad- create the XSLT code-> save that file as " .xsl"-> zip that and them import it under ESR.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi,

XML code expect the end tag it same as start tag.

But in your output structure case your XML looks like there is no end tag for every tag. So might be this is wrong structure.

But i think this below structure is possible to use by XSLT mapping

<CalYearMonth01>201201</CalYearMonth01>

<CalYearMonth02>201201</CalYearMonth02>

<CalYearMonth03>201201</CalYearMonth02>

.

.

.

<CalYearMonth26>201201</CalYearMonth026>

<TotalRevenus01>592421.60</TotalRevenus01>

<TotalRevenus02>592421.60</TotalRevenus02>

<TotalRevenus03>592421.60</TotalRevenus03>

.

.

.

<TotalRevenus26>592421.60</TotalRevenus26>

Thank you,

Sateesh

Former Member
0 Kudos

Yes Satish you are right.

I want the O/P as u said above. I am not ware of xslt Mapping. can u guide me how to do. Thanks in adv..

Vankadoath

Former Member
0 Kudos

Hi,

First one thing confirm me why your choosing the values upto 26.

is this default ?

thank you

sateesh