Solved

Xsl Nested Loop

Posted on 2011-02-18
4
36 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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.
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 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…

728 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