cancel
Showing results for 
Search instead for 
Did you mean: 

xsl:for-each help

Former Member
0 Kudos

Hi All,

Can anyone let me know how can I write xsl:for-each for below select query.

<xsl:if test="$loopControl= 2">

<xsl:value-of select="substring(E1MVKEM/VKORG,0,2)" />

</xsl:if>

<xsl:if test="$loopControl= 1">

<xsl:value-of select="substring(E1MVKEM/VKORG,0,2)" />

</xsl:if>

When I write as below I get an error.

<xsl:for-each select="substring(E1MVKEM/VKORG,0,2)" />

Thanks in advance,

Hemal

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I want that to loop below mulitple times of MVKEM. There are multiple MVKEM with differnt VKORG in each, for example (FR and US) If I loop like

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

<xsl:value-of select="substring(E1MVKEM/VKORG,0,2)" />

</xsl:for-each>

then it gives out put as

<ComplexValue Key="FRFR">

whereas the output should be

<ComplexValue Key="FR">

and the next time

<ComplexValue Key="US">

Regards,

Hemal

moorthy
Active Contributor
0 Kudos

Hi,

<i><xsl:for-each select="E1MVKEM">

<xsl:value-of select="substring(E1MVKEM/VKORG,0,2)" />

</xsl:for-each></i>

>>>Here try to give absolute path in for-each statementand test it i.e from root level

Have a look into this also-

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

Hope this helps,

Regards,

Moorthy

henrique_pinto
Active Contributor
0 Kudos

If you want to get the first two characters of the string, use substring(xxx, 1, 2).

In XSLT, unlike Java, the 1st position of an array has index = 1.

Regards,

Henrique.