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

asked on

xslt for each statement and trimming string

My following for each woks but...
The output is AL, AK, AZ,

How do I trim the last comma off?

<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>
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

just posted that in your other question
(I saw that one coming :-)

     <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>
Avatar of Larry Brister

ASKER

uhhh...
That put everything in the xml in this one tag...with a leading comma...and then my states with no commas

I just need to remove the last comma in this particular "for-each"

Following is ALL this templates code...
The for-each in question is at the bottom end.


<xsl:template match="root">
        <DIV style="margin-bottom:20px;">
            <tr>
                <td class="myTD">
                    <fieldset class="myFieldSet">
                        <legend class="legendTitle">General Information</legend>
                        <table cellpadding="0" cellspacing="0" border="0" class="generalDescr">
                            <tr>
                                <td style="font-size:12px;">
                                    <strong style="width:120px;">Name:</strong>&#160;<xsl:value-of select="FirstName"/>&#160;<xsl:value-of select="MiddleInitial"/>&#160;<xsl:value-of select="LastName"/>&#160;&#160;&#160;&#160;&#160;<strong>Goes by:</strong>&#160;<xsl:value-of select="PrefName"/>
                                </td>
                            </tr>
                            <tr>
                                <td style="font-size:12px;">
                                    <strong style="width:120px;">Address:</strong>&#160;<xsl:value-of select="Address"/>&#160;<xsl:value-of select="City"/>,&#160;<xsl:value-of select="StateProv"/>&#160;<xsl:value-of select="Zip"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong style="width:120px;">Email Address:</strong>&#160;<a>
                                        <xsl:attribute name="href">
                                            mailto:<xsl:value-of select="Email" />
                                        </xsl:attribute>
                                        <xsl:value-of select="Email" />
                                    </a>

                                </td>

                            </tr>
                        </table>
                    </fieldset>
                    <br />
                    <fieldset class="myFieldSet2">
                        <legend class="legendTitle">Detail Information</legend>
                        <table cellpadding="0" cellspacing="0" border="0" class="detailInfo">
                            <tr>
                                <td>
                                    <strong style="width:120px;">SSAN:</strong>&#160;<xsl:value-of select="SSN"/>&#160;&#160;&#160;&#160;&#160;<strong>Birth Date:</strong>&#160;<xsl:value-of select="BirthDate"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong style="width:120px;">Available After:</strong>&#160;<xsl:value-of select="AvailAfterDate"/>&#160;
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong style="width:140px;">Auth. work in US:</strong>&#160;<xsl:value-of select="Authorized"/>&#160;
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                    <br />
                    <fieldset class="myFieldSet3">
                        <legend class="legendTitle">Telephone Numbers</legend>
                        <table cellpadding="0" cellspacing="0" border="0" class="telInfo">
                            <tr>
                                <td>
                                    <strong>Main:</strong>&#160;<xsl:value-of select="MainPhone"/>&#160;&#160;&#160;<strong>Cell:</strong>&#160;<xsl:value-of select="CellPhone"/>&#160;&#160;&#160;<strong>Assigned:</strong>&#160;<xsl:value-of select="AssignPhone"/>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                    <br />
                    <fieldset class="myFieldSet3">
                        <legend class="legendTitle">Education</legend>
                        <table cellpadding="0" cellspacing="0" border="0" class="edInfo">
                            <tr>
                                <td style="width:150px; font-weight:bold;">
                                    School
                                </td>
                                <td style="width:150px; font-weight:bold;">
                                    City
                                </td>
                                <td style="width:75px; font-weight:bold;">
                                    State
                                </td>
                                <td style="width:75px; font-weight:bold;">
                                    Grad Date
                                </td>
                                <td align="center" style="width:150px; font-weight:bold;">
                                    Dimploma
                                </td>
                            </tr>
                            <xsl:for-each select="Education/School">
                                <tr>
                                    <td style="width:150px;">
                                        <xsl:value-of select="SchoolName"/>
                                    </td>
                                    <td style="width:150px;">
                                        <xsl:value-of select="SchoolCity"/>
                                    </td>
                                    <td style="width:75px;">
                                        <xsl:value-of select="SchoolState"/>
                                    </td>
                                    <td style="width:75px;">
                                        <xsl:value-of select="GraduateMonth"/>/<xsl:value-of select="GraduateYear"/>
                                    </td>
                                    <td align="center" style="width:150px;">
                                        <xsl:value-of select="Degree"/>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>
                    </fieldset>
                    <br />
                    <fieldset class="myFieldSet3">
                        <legend class="legendTitle">Licensure</legend>
                        <table cellpadding="0" cellspacing="0" border="0" class="edInfo">
                            <tr>
                                <td style="width:150px; ">
                                    Specialty
                                </td>
                                <td colspan="2" style="font-weight:bold;">
                                    States licensed (Acitve and Inactive)
                                </td>

                            </tr>                            
                                <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>
                           
                        </table>
                    </fieldset>
                </td>
            </tr>
        </DIV>
    </xsl:template>
The lines I posted replace only the inner for-each you posted
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
Perfect!
There is one more follow-up question for different element need.