Solved

call template when values match. part2

Posted on 2013-01-04
3
202 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in good tutorials for PHP, HTML and CSS 6 52
Change box shadow 1 34
Text color in a select 11 22
XSL for-each loop - Excluding specific text 4 10
This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

740 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