Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:37:48+00:00 2026-05-27T08:37:48+00:00

I am having trouble reading out my nested for-each loops. For some reason, it

  • 0

I am having trouble reading out my nested for-each loops. For some reason, it doesn’t loop under the direct nodes. The trouble seems to be with the tages.My first loop happens after I open the table, and I loop through the whole table for the admin reports and nest the second node underneath it. This works fine, but when I go to nest additional nodes underneath, I am able to pull the values, but not specific to the parent node. My eyes are pretty much bloodshot from this exercise, could someone lend some help. Thanks in advance.

XSL:

    <tr bgcolor="9acd32">
    <table><th>Data Source Name:</th></table>
    <table><th><xsl:value-of select="@Value"/>   </th></table>
    </tr>
    <tr> 
   <xsl:for-each select="*[name()='PartInformation']">  
       <table bgcolor="#99ff66"><th>Part Information:</th></table>
       <table bgcolor="#99ff66"><th><xsl:value-of select="@Value"/></th></table>       
   <tr> 
    <xsl:for-each select="*/*[name()='InspPrgInformation']">    
       <table bgcolor="#33ccff"><th>Inspection Program ID:</th></table>
       <table bgcolor="#33ccff"><th><xsl:value-of select="@Value"/></th></table>
    <table bgcolor="#33ccff"><th><xsl:value-of select="@NoOfTracefields"/></th></table>
    </xsl:for-each>
    </tr>
    </xsl:for-each>
    </tr>         
<tr> 
   <xsl:for-each select="*/*/*[name()='AreaInformation']">    
       <table bgcolor="#FFFF99"><th>Area Information:</th></table>
       <table bgcolor="#FFFF99"><th><xsl:value-of select="@Area"/></th></table>
       <table bgcolor="#FFFF99"><th><xsl:value-ofselect="@AreaCount"/>         
  </th></table>
   </xsl:for-each>
   </tr>

 </xsl:for-each>
</table>
</center>

XML:

 <AdminReports xmlns="30/11/2011 09:25:58">

  <AdminReport ID="1">
    <DataSourceInformation DataSourceID="2" Value="DCS_AERO_KINSTON_DCS350">
      <PartInformation PartID="8" Value="WithAreaInfo">
        <InspPrgInformation InspPrgID="10" Value="DCS350_Sec15Drill_Pannel1WithInfo"       NoOfTracefields="1">          
          <AreaInformation Area="L3" AreaCount="59"/>
          <AreaInformation Area="L4" AreaCount="45"/>
          <AreaInformation Area="LT4" AreaCount="54"/>
        </InspPrgInformation>
      </PartInformation>
      <PartInformation PartID="9" Value="NoAreaInfo">
        <InspPrgInformation InspPrgID="9" Value="DCS350_Sec15Trim_Pannel1" NoOfTracefields="0"/>
      </PartInformation>
    </DataSourceInformation>
  </AdminReport>

  <AdminReport ID="2">
    <DataSourceInformation DataSourceID="2" Value="DCS_AERO_KINSTON_DCS350">
      <PartInformation PartID="8" Value="NoAreaInfo">
        <InspPrgInformation InspPrgID="10" Value="WithInfo" NoOfTracefields="1">          

        </InspPrgInformation>
      </PartInformation>
      <PartInformation PartID="9" Value="AreaInfo">
        <InspPrgInformation InspPrgID="9" Value="DCS350_Sec15Trim_Pannel1" NoOfTracefields="0">
          <AreaInformation Area="L4" AreaCount="75"/>
          <AreaInformation Area="LT4" AreaCount="4"/>
        </InspPrgInformation>
      </PartInformation>
    </DataSourceInformation>
  </AdminReport>
</AdminReports>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:37:48+00:00Added an answer on May 27, 2026 at 8:37 am

    What you are doing is wrong for what you want to achieve:

    <xsl:for-each select="*[name()='PartInformation']">  
       <table bgcolor="#99ff66"><th>Part Information:</th></table>
       <table bgcolor="#99ff66"><th><xsl:value-of select="@Value"/></th></table>       
       <tr> 
       <xsl:for-each select="*/*[name()='InspPrgInformation']">    
           <table bgcolor="#33ccff"><th>Inspection Program ID:</th></table>
           <table bgcolor="#33ccff"><th><xsl:value-of select="@Value"/></th></table>
        <table bgcolor="#33ccff"><th><xsl:value-of select="@NoOfTracefields"/></th></table>
        </xsl:for-each>
        </tr>
    </xsl:for-each>
    

    The second for each is by no means related with the first one. Same goes with your third for-each.

    Do not the the current() will give you the currently iterated node.

    You could rewrite your first two for-each like this :

    <tr>
                <xsl:for-each select="*[name()='PartInformation']">
                    <tr>
                        <xsl:for-each select="current()/*/InspPrgInformation">
                            <table bgcolor="#33ccff">
                                <th>Inspection Program ID:</th>
                            </table>
                            <table bgcolor="#33ccff">
                                <th>
                                    <xsl:value-of select="@Value"/>
                                </th>
                            </table>
                            <table bgcolor="#33ccff">
                                <th>
                                    <xsl:value-of select="@NoOfTracefields"/>
                                </th>
                            </table>
                        </xsl:for-each>
                    </tr>
                </xsl:for-each>
            </tr>
    

    The third one can be used with your current design. Because current() is local to each for-each, so your third for-each has no idea about the other two. In addition your design seems to be using xslt as a programming language which is not the way to go.

    Finally try to provide some complete/compilable examples next time as well as your target document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading Clean Code and having trouble figuring out how to keep some
I'm having some trouble reading data from a file into a vector of Orders.
I've been reading through Programming Clojure, and I've been having some trouble understanding Stuarts
I am having some trouble reading some data from a serial port I opened
I'm having some trouble with multi-layer pointers. Basically I'm reading point locations from a
Im having trouble reading from a CSV file final String DELIMITER = ,; Scanner
I'm having trouble reading a chunked response when using a StreamReader to read the
I'm having trouble reading and writing QByteArray data to a file. My goal is
I'm having trouble reading dark blue on black when I turn on syntax colours
I'm creating a sub dialog another vendor is calling. I'm having trouble reading the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.