我在使用奇偶类创建XSL到XML时遇到问题

我在使用奇偶类创建XSL到XML时遇到问题,xml,xslt,parent,axes,Xml,Xslt,Parent,Axes,您好,我对XSL有问题 我的意见是: <tr class="odd"> <th scope="row" class="country" rowspan="2"><a href="">Abkhazia</a></th> <th class="category" scope="row">Landlines</th> <th class="locality" scope="row">All Landline

您好,我对XSL有问题

我的意见是:

<tr class="odd">
<th scope="row" class="country" rowspan="2"><a href="">Abkhazia</a></th>
<th class="category" scope="row">Landlines</th>
<th class="locality" scope="row">All Landlines</th>
<td class="rate">11.9c</td>
</tr>
<tr class="odd">
<th class="category" scope="row">Mobiles</th>
<th class="locality" scope="row">All Networks</th>
<td class="rate">16.8c</td>
</tr>
<tr class="even">
<th scope="row" class="country" rowspan="4"><a>Algeria</a></th>
<th class="category" scope="row">Landlines</th>
<th class="locality" scope="row">All Landlines</th>
<td class="rate">5.5¢</td>
</tr>
<tr class="even">
<th class="category" scope="row" rowspan="3">Mobiles</th>
<th class="locality" scope="row">Algeria Telecom Satellite, Divona Satellite, Orascom Satellite</th>
<td class="rate">6.4¢</td>
</tr>
<tr class="even">
<th class="locality" scope="row">Mobilis</th>
<td class="rate">21.6¢</td>
</tr>
<tr class="even">
<th class="locality" scope="row">Djezzy, Nedjma, Wataniya</th>
<td class="rate">34.9¢</td>
</tr>
<xsl:template match="//xhtml:tr" mode="list">

    <xsl:variable name="countryName" select="normalize-space(xhtml:th[@class = 'country'])"/>
    ...
    ...
    ...
<country>
    <xsl:attribute name="name">
        <xsl:value-of select="$countryName"/>
    </xsl:attribute>
    <rate>
    ...
    </rate>
</country>

固定电话
所有固定电话
11.9c
手机
所有网络
16.8c

我的问题从第156行开始,比如:

...
<xsl:for-each select="tbody/tr">
<country>
    <xsl:attribute name="name">
        <xsl:choose>
            <xsl:when test="th[@class='country']">
                <xsl:value-of select="th[@class='country']"/>       
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="preceding-sibling::tr[th/@class='country'][1]/th[@class='country']"/>    
            </xsl:otherwise>
        </xsl:choose>
    </xsl:attribute>

    <rate>
        <!-- insert attributes -->
        <xsl:value-of select="td[@class='rate']"/>      
    </rate>
</country>
</xsl:for-each>
...
。。。
...

我应该补充一点,这种格式有点不正确:每个“国家”都有一个利率。我不明白你为什么需要这个包装;将国家作为一个属性添加到比率中更符合逻辑。

第二个
不应该是“偶数”吗?不。。。它有成对的,或三个,两个或三个tr和奇数,然后两个或三个tr和evenI可以给你整个XML的链接。。。所以,我的问题从156Ok行开始,那么阿尔及利亚的预期产量是多少?我的问题是。。。你可以看到我需要什么,我有什么
  <country name="Abkhazia">
      <rate type="Landlines" operator="All Landlines" currency="EUR" vat="0" unit="minute">11.9</rate>    
   </country>

  <country name="Algeria">
      <rate type="Landlines" operator="All Landlines" currency="EUR" vat="0" unit="minute">5.5</rate>
   </country>
   <country name="">
      <rate type="Mobiles" operator="Algeria Telecom Satellite, Divona Satellite, Orascom Satellite" currency="EUR" vat="0" unit="minute">6.4</rate>
   </country>
   <country name="">
      <rate type="" operator="Mobilis" currency="EUR" vat="0" unit="minute">21.6</rate>
   </country>
   <country name="">
      <rate type="" operator="Djezzy, Nedjma, Wataniya" currency="EUR" vat="0" unit="minute">34.9</rate>
   </country>
...
<xsl:for-each select="tbody/tr">
<country>
    <xsl:attribute name="name">
        <xsl:choose>
            <xsl:when test="th[@class='country']">
                <xsl:value-of select="th[@class='country']"/>       
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="preceding-sibling::tr[th/@class='country'][1]/th[@class='country']"/>    
            </xsl:otherwise>
        </xsl:choose>
    </xsl:attribute>

    <rate>
        <!-- insert attributes -->
        <xsl:value-of select="td[@class='rate']"/>      
    </rate>
</country>
</xsl:for-each>
...