Solved

call template when values match. part2

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

911 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

17 Experts available now in Live!

Get 1:1 Help Now