xsl for each statement and repeat direction

Larry Brister
Larry Brister used Ask the Experts™
on
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>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Information Architect
Top Expert 2006
Commented:
sounds as if you need

    <xsl:for-each select="StatesLicensed/State">
            <xsl:value-of select="."/>,&#160;
        </xsl:for-each>

But we can only help you for sure if you also posted some source XML
and told us in which context (template match attribute) thsi XSLT snippet plays
Larry Bristersr. Developer

Author

Commented:
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>
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial