Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

xsl for each statement and repeat direction

I'm trying to make my for-each repeat horizontally.

However...the following simply grabs value of the last state in the child nodes "AZ"
My desired output is AL,AK,AZ


<tr>
    <td style="width:150px;">
        <xsl:value-of select="Specialty"/>
    </td>
    <td colspan="2">
        <xsl:for-each select="StatesLicensed">
            <xsl:value-of select="State"/>,&#160;
        </xsl:for-each>
    </td>
</tr>
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Perfect.
Watch for follow-up question
This was my final code...
Haven't done much xslt...thanks.

<tr>
    <td style="width:150px;">
        <xsl:value-of select="Specialty"/>
    </td>
    <td colspan="2">
       <xsl:for-each select="StatesLicensed/State"> <xsl:value-of select="."/>,&#160;
   </xsl:for-each>
    </td>
</tr>
Welcome

If you added a test, you would not see the ',' at the end

     <xsl:for-each select="StatesLicensed/State">
<xsl:if test="not(position() = 1)"><xsl:text>,&#160;</xsl:text></xsl:if>
<xsl:value-of select="."/>
   </xsl:for-each>

Please give us some source XML in your next question