Solved

Xsl Nested Loop

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
character entities and entity references in XML 17 110
I starting with php 12 112
ColdFusion Rereplace 3 71
XML XSL Choose example 3 17
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

930 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

10 Experts available now in Live!

Get 1:1 Help Now