cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping

Former Member
0 Kudos

Hi Experts,

I am having requirement that if in the source mapping, particular node is not exists then i need to map any constant value to source node

like "map with default " in graphical mapping.

what should i have to do in XSL style sheet transformation.

thanks and regards

anup banerjee

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

it is very easy,create one varaible in XSL and the vairable should have address of your source field(XPATH)

refer below link it helps you to frame the logic

http://www.tek-tips.com/viewthread.cfm?qid=1273804

Regards,

Raj

Former Member
0 Kudos

hi Raj ,

i agreed at your point .

using "<xsl:if>" i can do but is there any other  technique like some default technique for the same.

if yes  please let me know.

because in my scenario having many source fields in that  i have to check this.

thanks and regards

anup Banerjee

Former Member
0 Kudos

Hi,

I think there is no other way....in XSLT mapping you have to check the existence of the filed and then do your further operations...

http://scn.sap.com/thread/1602917

I would suggest that you can add one extra message mapping before the xslt and there you can check whether the source filed exist or not. So by doing this you always make sure that xslt will get value (actual one or default value)..

Thanks

Amit Srivastava

iaki_vila
Active Contributor
0 Kudos

You could avoid the "<xsl:if>" clausule with this way:

<xsl:variable name="color">

   <xsl:choose>

     <xsl:when test="@color">

       <xsl:value-of select="@color"/>

     </xsl:when>

     <xsl:otherwise>green</xsl:otherwise>

   </xsl:choose>

</xsl:variable>

Declare a variable named "color". Set its value to the color attribute of the current element. If the current element has no color attribute, the value of "color" will be "green":

Extracted from: http://www.w3schools.com/xsl/el_when.asp

But I prefer the clausule if, it isn't too bad

Regards.

former_member184681
Active Contributor
0 Kudos

Hi,

Why don't you use graphical mapping then, if your requirement is to use one of its typical features? With XSLT, you would have really a lot of additional work (declaring a variable for each field and so on), and no chance to debug once something goes wrong in the future. Changing the whole mapping into a graphical one might still turn out to be the simplest solution.

Hope this helps,
Greg

Answers (0)