Solved

call template when values match. part2

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

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.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
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…

738 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