从两个不同节点XSLT获取最大值



我无法从 nrofconvoys andotationText 节点找到最大值。

<InstructionListPosition>
  <Instruction>
    <Navigation>
      <NrOfConvoys>2</NrOfConvoys>
      <annotationText>5</annotationText>
    </Navigation>
  </Instruction>
</InstructionListPosition>
<InstructionListPosition>
  <Instruction>
    <Navigation>
      <NrOfConvoys>20</NrOfConvoys>
      <annotationText>10</annotationText>
    </Navigation>
  </Instruction>
</InstructionListPosition>

我希望输出如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--Disable Cache-->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="pragma" content="no-cache" />
<!--End-->
</head>
<body>
<div id="wrapper_all">
	<table style="width:100%">
  <tr>
    <th>Sr. Num</th>
    <th>Maximum value</th> 
  </tr>
  <tr>
    <td>1</td>
    <td>5</td>     
  </tr>
    <tr>
    <td>2</td>
    <td>20</td>     
  </tr>
</table>
</div>
</body>
</html>

我想要如上所述的输出,请您提供最佳解决方案。我正在使用XSLT1.0。

请帮助我,谢谢。

使用以下:

<xsl:for-each select="InstructionListPosition">
                <tr>
                    <td>
                        <xsl:value-of select="position()"/>
                    </td>
                    <td>
                        <xsl:for-each
                            select=".//Navigation/*[self::NrOfConvoys or self::annotationText]">
                            <xsl:sort select="." order="descending"/>
                            <xsl:if test="position()=1">
                                <xsl:value-of select="."/>
                            </xsl:if>
                        </xsl:for-each>
                    </td>
                </tr>
            </xsl:for-each>

请参阅https://xsltfiddle.liberty-development.net/gwmuij1/1

相关内容

  • 没有找到相关文章

最新更新