Solved

call template when values match. part2

Posted on 2013-01-04
3
204 Views
Last Modified: 2013-01-04
i have the following xml input

<RS>
      <SAvailRQ>
            <Code>AL</Code>
            <FNum>131</FNum>
      </SAvailRQ>
<SMapRS>
  <SMapResponses>
      <SMapResponse>
            <SegInfo FNum="131">
                  <Departure LocationCode="MIA"/>
                  <Arrival LocationCode="LAX"/>
                  <Marketing Code="AL"/>
            </SegInfo>
            <SMapDetails>
            <CabClass CabinType="Economy" Name="AC DF">
                  <ARows>
                        <ARow RowNumber="12">
                              <ASeats>
                                    <ASeat Availability="A" Characteristics="W|K|F|PS" Number="A"/>
                              </ASeats>
                              <ARowCharacteristics CharacteristicList=""/>
                        </ARow>
                  </ARows>
                  </CabClass>
            </SMapDetails>
      </SMapResponse>
      <SMapResponse>
            <SegInfo FNum="118">
                  <Departure LocationCode="LAX"/>
                  <Arrival LocationCode="MIA"/>
                  <Marketing Code="AL"/>
            </SegInfo>      
            <SMapDetails>
                  <CabClass CabinType="Economy" Name="AC DF">
                        <ARows>
                              <ARow RowNumber="12">
                                    <ASeats>
                                          <ASeat Availability="A" Characteristics="W|K|F|PS" Number="A"/>
                                    </ASeats>
                                    <ARowCharacteristics CharacteristicList=""/>
                              </ARow>
                        </ARows>
                  </CabClass>
            </SMapDetails>
      </SMapResponse>      
   </SMapResponses>
</SMapRS>      
</RS>      


#1.
I need logic that will execute the follwing template
  <xsl:apply-templates select="SMapResponses/SMapResponse/SMapDetails/CabClass" mode="SDisplay"/>
 
if RS/SAvailRQ/FNum matches that found in RS/SMapRS/SMapResponses/SMapResponse/SegInfo/@FNum

per another question asked i have the following partial solution:
<xsl:variable name="this-fnum" select="ancestor::RS/SAvailRQ/FNum"/>
<xsl:apply-templates select="SMapResponses/SMapResponse/SegInfo[@FNum = $this-fnum]"/>

and this worked successfully but how do i apply this same concept new template call using SMapDetails grouped within SMapResponse?


#2.
similarly, i have for-each statement where again I need to have executed only when Fnum is found within xml


        <xsl:for-each select="SMapResponses/SMapResponse">                  //here only do this when Fnum is equal
            <xsl:variable name="pos" select="position()"/>
            <xsl:for-each select="SMapDetails/CabClass/ARows/ARow">
                        ....
            </xsl:for-each>
        </xsl:for-each>
0
Comment
Question by:badtz7229
[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
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 38745085
If I can safely assume that there is only one RS/SAvailRQ/FNum per document, start by making this a global variable (that is a variable right under the stylesheet element

<xsl:variable name="this-fnum" select="/RS/SAvailRQ/FNum"/>

Then, for
#1 <xsl:apply-templates select="SMapResponses/SMapResponse[SegInfo/@FNum=$this-fnum]/SMapDetails/CabClass" mode="SDisplay"/>

#2 <xsl:for-each select="SMapResponses/SMapResponse[SegInfo/@FNum=$this-fnum]">
0
 

Author Closing Comment

by:badtz7229
ID: 38745269
Gertone, this worked successfully.
thank you so much for your help.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 38745309
welcome
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Suggested Courses

626 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