Groups > Design > Microsoft xsl > Re: For-each statement




For-each statement

For-each statement
Mon, 24 Mar 2008 06:58:19 -070
I am real new to XSL processing, Hope somebody can help me out.  I
have this code and would only like process the first element of the
for-each statement.  I am not sure how to do that and I have been
searching for a solution. Any help would be appreciated.
Terry

<h2>Shipping Address</h2>
- <table cellspacing="0" border="1"
cellpadding="3" width="600">
- <tr>
  <td class="heading">Name</td>
  </tr>
- <xsl:for-each select="ActionItems">
- <xsl:for-each select="ActionItem">
- <tr class="actionitems">
- <td class="actionitems">
  <xsl:value-of select="@ShiptoName" />
  </td>
- <td class="actionitems">
  <xsl:value-of select="@Comments2" />
  </td>
  </tr>
- <tr class="actionitems">
- <td class="actionitems">
  <xsl:value-of select="@ShiptoStreet" />
  </td>
- <td class="actionitems">
  <xsl:value-of select="@Comments1" />
  </td>
  </tr>
- <tr class="actionitems">
- <td class="actionitems">
  <xsl:value-of select="@ShiptoCity" />
  </td>
  </tr>
- <tr class="actionitems">
- <td class="actionitems">
  <xsl:value-of select="@ShiptoState" />
  </td>
  </tr>
- <tr class="actionitems">
- <td class="actionitems">
  <xsl:value-of select="@ShiptoZip" />
  </td>
  </tr>
  </xsl:for-each>
  </xsl:for-each>
Post Reply
Re: For-each statement
Mon, 24 Mar 2008 15:06:52 +010
Tambrosi wrote:
> I am real new to XSL processing, Hope somebody can help me out.  I
> have this code and would only like process the first element of the
> for-each statement.  I am not sure how to do that and I have been
> searching for a solution. Any help would be appreciated.
> Terry
> 
> <h2>Shipping Address</h2>
> - <table cellspacing="0" border="1"
cellpadding="3" width="600">
> - <tr>
>   <td class="heading">Name</td>
>   </tr>
> - <xsl:for-each select="ActionItems">
> - <xsl:for-each select="ActionItem">

Well you can do
   <xsl:for-each select="ActionItems[1]">
to process only the first 'ActionItems' element or you can do
   <xsl:for-each select="ActionItems">
     <xsl:if test="position() = 1">
        <!-- put here what you want to do with first item -->
     </xsl:if>
   </xsl:for-each>
-- 

	Martin Honnen --- MVP XML
Post Reply
about | contact