Solved

Xsl Nested Loop

Posted on 2011-02-18
4
28 Views
Last Modified: 2016-05-30
I am trying to display a subset of data that matches based on the ExchangeWantedId.  How do I set this up?  Here is what I have thus far:

Here is the XML

<xs:element name="ExchangeWantedItemsMeToodUsers">
<xs:complexType>
- <xs:sequence>
  <xs:element name="ExchangeWantedId" type="xs:int" minOccurs="0" />
  <xs:element name="ExchangeWantedName" type="xs:string" minOccurs="0" />
  <xs:element name="MeTooer" type="xs:string" minOccurs="0" />
  <xs:element name="MeTooerBankName" type="xs:string" minOccurs="0" />
  <xs:element name="DateFulfilled" type="xs:string" minOccurs="0" />
  <xs:element name="DateFulfilledUnformated" type="xs:dateTime" minOccurs="0" />
  <xs:element name="UserID" type="xs:int" minOccurs="0" />
  <xs:element name="FullName" type="xs:string" minOccurs="0" />
  <xs:element name="PostedBankName" type="xs:string" minOccurs="0" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element name="ExchangeWantedItemsMeToodUsers1">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="ExchangeWantedID" type="xs:int" minOccurs="0" />
  <xs:element name="DisplayName" type="xs:string" minOccurs="0" />
  <xs:element name="FullName" type="xs:string" minOccurs="0" />
  </xs:sequence>
  </xs:complexType>
  </xs:element>
Here is the xsl

<xsl:for-each select="/root/ExchangeWantedItemsMeToodUsers">                
    <tr>
        <xsl:call-template name="AlternateRowColor" />
        <td><xsl:value-of select="ExchangeWantedName" /></td>
        <td>
            <xsl:for-each select="/root/ExchangeWantedItemsMeToodUsers">
                <xsl:value-of select="MeTooer" /> - <xsl:value-of
                                                    select="MeTooerBankName" />
            </xsl:for-each>
        </td>
        <td><xsl:value-of select="FullName" /> - <xsl:value-of
                                                select="PostedBankName" /></td>
        <td><xsl:value-of select="DateFulfilled" /></td>
    </tr>
</xsl:for-each>
0
Comment
Question by:mmahon512
  • 2
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 34931805
For being selective you could use predicates []
<xsl:for-each select="/root/ExchangeWantedItemsMeToodUsers">
could be something like this
<xsl:for-each select="/root/ExchangeWantedItemsMeToodUsers[ExchangeWantedId = $your-value]">

where $your-value is a variable you gave the test value earlier

or directly if you need that
<xsl:for-each select="/root/ExchangeWantedItemsMeToodUsers[ExchangeWantedId = 'foo']">

It strikes me that you have another loop inside your for-each, and that you also start from the root there
Please note that you have everything in context inside the loop
please explain what you want to achieve, with input and output document atteched, so I can help
0
 

Expert Comment

by:EE_AutoDeleter
ID: 41623293
I've requested that this question be deleted for the following reason:

                           
No comment has been added to this question in more than 21 days, so it is now classified as abandoned and is now flagged for deletion.


If there is a valid solution, please OBJECT and indicate the comments that are, or would otherwise lead to, a solution.


Use the specific format https:#axxxxxxxx for comment ID(s).


Also, please don't object simply because the author did not respond to your comment. While we understand this is frustrating, unfortunately we cannot force the author to return to the question. Unless you feel you have presented a valid, verifiable solution we'll simply delete the question.


Experts-Exchange Auto Deleter
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 41623294
https:#a34931805 contains an general good advice above selectivity in apply templates / for-each AND it contains an important suggestion about inner context of a for-each loop, something a lot of XSLT beginners struggle with

Please accept that comment as an answer
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question