Xml XSL for each只获取第一个节点值

Xml XSL for each只获取第一个节点值,xml,xslt,xpath,Xml,Xslt,Xpath,以下是我的XSLT文件中的foreach: <xsl:for-each select="/flights/flight/route[../plane/name/. ='Airbus 330']/routename"> <tr> <td> <xsl:attribute name="colspan" >2</xsl:attribute><xsl:attribut

以下是我的XSLT文件中的foreach:

<xsl:for-each select="/flights/flight/route[../plane/name/. ='Airbus 330']/routename"> 
        <tr>
            <td>
                <xsl:attribute name="colspan" >2</xsl:attribute><xsl:attribute name="style" >text-align:center</xsl:attribute><a><xsl:attribute name="href">map.php?a=<xsl:value-of select="/flights/flight/route[../plane/name/. =$a]/from/latitude" />&amp;b=<xsl:value-of select="/flights/flight/route[../plane/name/. =$a]/from/longitude" />&amp;c=<xsl:value-of select="/flights/flight/route[../plane/name/. =$a]/to/latitude" />&amp;d=<xsl:value-of select="/flights/flight/route[../plane/name/. =$a]/to/longitude" />&amp;e=<xsl:value-of select="/flights/flight/route[../plane/name/. =$a]/routename" /></xsl:attribute>
                <xsl:value-of select="/flights/flight/route[../plane/name/. ='Airbus 330']/routename"/></a>
            </td>
        </tr>
    </xsl:for-each> 

2文本对齐:居中
有两条路线有一个空中客车330飞机,当为每一条路线运行该飞机时,它会根据需要创建两个表行和链接,但使用第一个routename两次,而不是每个routename。为什么会这样

以下是XML文件:

<?xml version="1.0" encoding="UTF-8"?>

<flights
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="flights.xsd">

<flight flightid="1">
    <flightno>EK98</flightno>
    <callsign>UAE98</callsign>
    <airline>Emirates Airline</airline>

    <plane planeid="1">
        <name>Airbus 330</name>
        <speed>567</speed>
        <registereddate>07-06-10</registereddate>
    </plane>

    <registration>3A6-EDJ</registration>
    <altitude height="feet">41000 feet</altitude>
    <speed ratio="mph">564 mph</speed>

    <route>
    <routename>Fiumicino-Dubai</routename>
    <course bearing="degrees">154 degrees</course>
    <distance type="miles">2697 miles</distance> 
    <duration>PT5H30M</duration>

        <from>
            <iatacode>FCO</iatacode>
            <airport>Fiumicino</airport>
            <country>Italy</country>
            <city>Rome</city>
            <latitude>41.8044</latitude>
            <longitude>12.2508</longitude>
        </from>

        <to>
            <iatacode>DXB</iatacode>
            <airport>Dubai Intl</airport>
            <country>UAE</country>
            <city>Dubai</city>
            <latitude>25.2528</latitude>
            <longitude>55.3644</longitude>
        </to>
    </route>

</flight>


<flight flightid="2">
    <flightno>BA283</flightno>
    <callsign>BAW283</callsign>
    <airline>British Airways</airline>

    <plane planeid="2">
        <name>Airbus 330</name>
            <speed>567</speed>
        <registereddate>06-12-97</registereddate>
    </plane>


    <registration>3A6-EDJ</registration>
    <altitude height="feet">41000 feet</altitude>
    <speed ratio="mph">564 mph</speed>

    <route>
        <routename>London-L.A</routename>
        <course bearing="degrees">154 degrees</course>
        <distance type="miles">5441 miles</distance> 
        <time>PT11H5M</time>
        <from>

            <iatacode>LHR</iatacode>
            <airport>Heathrow</airport>
            <country>England</country>
            <city>London</city>
            <latitude>51.4775</latitude>
            <longitude>0.4614</longitude>
        </from>

        <to>
            <iatacode>LAX</iatacode>
            <airport>Los Angeles Intl</airport>
            <country>USA</country>
            <city>L.A</city>
            <latitude>33.9471</latitude>
            <longitude>-118.4082</longitude>
        </to>
    </route>

</flight>

</flights>

EK98
阿联酋98
阿联酋航空公司
空中客车330
567
07-06-10
3A6-EDJ
41000英尺
564英里/小时
迪拜菲米西诺酒店
154度
2697英里
PT5H30M
FCO
菲米奇诺
意大利
罗马
41.8044
12.2508
DXB
迪拜国际酒店
阿拉伯联合酋长国
迪拜
25.2528
55.3644
BA283
BAW283
英国航空公司
空中客车330
567
06-12-97
3A6-EDJ
41000英尺
564英里/小时
伦敦洛杉矶
154度
5441英里
PT11H5M
LHR
希思罗机场
英格兰
伦敦
51.4775
0.4614
松懈的
洛杉矶国际酒店
美国
洛杉矶
33.9471
-118.4082

只需将
替换为
。在每个的
中,
路由名称
是上下文节点,您希望输出该节点(而不是在文档中启动新的导航)。

感谢这一点,链接现在是两个不同的路由名称,但传递的参数仍然是第一组,您能告诉我如何迭代到下一组参数吗,我尝试了这个方法,但没有成功:map.php?a=当您将
路由名
作为上下文节点处理时,您需要
,它先到达父
路由
,然后从/latitude
子代访问
。作为第三个选项,您可以更改每个
,以处理
路由
元素,然后您可以使用
。非常感谢您的帮助,我也了解了更多这方面的工作原理。谢谢