Nesting <xsl:for-each> statements?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Nesting <xsl:for-each> statements?

  1. #1
    rj Guest

    Nesting <xsl:for-each> statements?


    Is it illegal to have nested <xsl:for-each> statements? I'm trying to populate
    the contents of a drop-down box inside a table using the code below. The
    "outer" for-each statement works fine. It is just inserting data into the
    table one row at a time. However, what I need the "inner" for-each statement
    to do is to grab the elements from another data island on my page, and insert
    them into the drop down box. This needs to be repeated for each iteration
    of the "outer" for-each loop. I'm about to stop the insanity and build this
    table out using the DOM. Any ideas??
    Thanks!

    <xsl:for-each select="RootNode/Records/row">
    <tr>
    <td class="label"><xsl:value-of select="@Description"/></td>
    <td class="label"><input id="txtLimit{@SubCoverageID}" type="text" maxlength="7"
    size="7" value="{@Limit}"/></td>
    <td class="label">
    <select id="selDeductible{@SubCoverageID}">
    <xsl:for-each select="RootNode/Deductible/MenuItem">
    <option><xsl:value-of select="Item"/></option>
    </xsl:for-each>
    </select>
    </td>
    <td class="label"><span id="spnPremium{@Premium}"></span></td>
    </tr>
    </xsl:for-each>

  2. #2
    Min Guest

    Re: Nesting <xsl:for-each> statements?


    I've done some similar stuff before, and got it to work when the inner loop
    referred to the nodes with ".." (ex. ../row). I think you just have to think
    carefully about which node each iteration is pointing to in the outer loop
    and compose the inner loop accordingly.
    good luck,

    "rj" <rpjolly@yahoo.com> wrote:
    >
    >Is it illegal to have nested <xsl:for-each> statements? I'm trying to populate
    >the contents of a drop-down box inside a table using the code below. The
    >"outer" for-each statement works fine. It is just inserting data into the
    >table one row at a time. However, what I need the "inner" for-each statement
    >to do is to grab the elements from another data island on my page, and insert
    >them into the drop down box. This needs to be repeated for each iteration
    >of the "outer" for-each loop. I'm about to stop the insanity and build

    this
    >table out using the DOM. Any ideas??
    >Thanks!
    >
    ><xsl:for-each select="RootNode/Records/row">
    > <tr>
    > <td class="label"><xsl:value-of select="@Description"/></td>
    > <td class="label"><input id="txtLimit{@SubCoverageID}" type="text" maxlength="7"
    >size="7" value="{@Limit}"/></td>
    > <td class="label">
    > <select id="selDeductible{@SubCoverageID}">
    > <xsl:for-each select="RootNode/Deductible/MenuItem">
    > <option><xsl:value-of select="Item"/></option>
    > </xsl:for-each>
    > </select>
    > </td>
    > <td class="label"><span id="spnPremium{@Premium}"></span></td>
    > </tr>
    ></xsl:for-each>



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center