1

I am using a marketing platform to implement an airline confirmation message. The platform allows us to write xsl to loop through values returned from the database. What i want to be able to do is to check this entire path

/Msg/Props/bookingcontact_to_booking/passenger_to_bookings/passenger_to_booking/passseg_to_passengers/passseg_to_passenger/passsegfee_to_passengersegments/passsegfee_to_passengersegment/

to see if any elements in the final table "passsegfee" have a node with a particular value. If there arent any then i want to display "None" and thats it. If there are any with that value i want to loop through just those elements to display them. I apologize for not having the xml structure to look at, but my xsl for this section is below.

    <xsl:for-each select="/Msg/Props/bookingcontact_to_booking/passenger_to_bookings/passenger_to_booking">
        <tr id="Pax-DataRow">
            <td height="22" width="200">
                <xsl:value-of select="Prop[@prop_name = 'firstname']/@val" />&#160;<xsl:value-of select="Prop[@prop_name = 'lastname']/@val" />
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="passseg_to_passengers/passseg_to_passenger/passsegfee_to_passengersegments/passsegfee_to_passengersegment/Prop[@prop_name = 'feetype']/@val != 'SSR'">
                        None
                    </xsl:when>
                    <xsl:otherwise>                     
                        <table style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; color: rgb(51, 51, 51);" >
                            <xsl:for-each select="passseg_to_passengers/passseg_to_passenger">
                                <xsl:for-each select="passsegfee_to_passengersegments/passsegfee_to_passengersegment">                          
                                    <xsl:if test="Prop[@prop_name = 'feetype']/@val = 'SSR'">
                                        <tr>
                                            <td align="left">
                                                <xsl:value-of select="Prop[@prop_name = 'feedescription']/@val" /><br/>
                                            </td>
                                        </tr>
                                    </xsl:if>
                                </xsl:for-each>
                            </xsl:for-each>
                        </table>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:value-of select="Prop[@prop_name = 'fsnumber']/@val" />
            </td>
        </tr>
        <xsl:if test="Prop[@prop_name = 'infantname']/@val != ''">
            <tr id="Pax-DataRow">
                <td height="22">                    
                    <xsl:value-of select="Prop[@prop_name = 'infantname']/@val" />
                </td>
                <td>
                    Infant
                </td>
                <td></td>
            </tr>
        </xsl:if>
    </xsl:for-each>

</xsl:template>

I am not sure if i am able to use the xpath axes like descendent or ancestor to achieve something similar, but when I run this in the marketing platform it displays "None" even when it shouldnt.

4

1 回答 1

1

好吧,不确定这是否能解决问题,但这条路径存在问题:

passseg_to_passengers/passseg_to_passenger/passsegfee_to_passengersegments
      /passsegfee_to_passengersegment/Prop[@prop_name = 'feetype']/@val != 'SSR'

如果任何费用类型不等于“SSR”,这将产生 true。要检查是否缺少值,您可以执行以下操作:

not(passseg_to_passengers/passseg_to_passenger/passsegfee_to_passengersegments
      /passsegfee_to_passengersegment/Prop[@prop_name = 'feetype']/@val = 'SSR')
于 2013-08-07T03:26:07.130 回答