我无法从 NrOfConvoys 中找到最大值,而 annotationText 下面的节点是我的XML文件。
<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>
&#13;
我想要如上所示的输出,请您提供最佳解决方案。我正在使用XSLT1.0。
请帮帮我,谢谢。
答案 0 :(得分:1)
使用它:
<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>
处的转化