Solved

call template when values match. part2

Posted on 2013-01-04
3
198 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
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
Comment Utility
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
Comment Utility
Gertone, this worked successfully.
thank you so much for your help.
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
welcome
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

763 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

7 Experts available now in Live!

Get 1:1 Help Now