我刚接触XSLT,有一个问题需要我在内部for-each的外部循环中访问元素的值。我的XML如下所示:
<searchresults>
<journeygroup>
<journeygroupnum>1</journeygroupnum>
<journeydetails>
<flightsegments>1</flightsegments>
<journeyid>1</journeyid>
<currency>USD</currency>
<fare>399.00</fare>
<taxes>99.00</taxes>
<flights>
<segmentid>1</segmentid>
<legid>1</legid>
<marketingcarrier>DL</marketingcarrier>
<operatingcarrier>DL</operatingcarrier>
<flightnum>9695</flightnum>
</flights>
</journeydetails>
<journeydetails>
<flightsegments>1</flightsegments>
<journeyid>2</journeyid>
<currency>USD</currency>
<fare>459.00</fare>
<taxes>129.00</taxes>
<flights>
<segmentid>1</segmentid>
<legid>1</legid>
<marketingcarrier>AA</marketingcarrier>
<operatingcarrier>AA</operatingcarrier>
<flightnum>5070</flightnum>
</flights>
</journeydetails>
</journeygroup>
</searchresults>
我的XSLT文档的一部分如下所示:
<table>
<xsl:for-each select="searchresults/journeygroup/journeydetails">
<xsl:for-each select="flights[segmentid='1']">
<tr>
<td><xsl:value-of select="marketingcarrier"/></td>
<td><xsl:value-of select="operatingcarrier"/></td>
<td><xsl:value-of select="flightnum"/></td>
<!-- Here I would like to add columns with the currency and fare from the outer loop -->
<td>currency</td>
<td>fare</td>
</tr>
</xsl:for-each>
</xsl:for-each>
<table>
如何在内部 for-each 循环中访问外部循环中的 currency 和 fare 节点中的值。