Solved

Xsl Nested Loop

Posted on 2011-02-18
4
21 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now