gpt4 book ai didi

xslt - 在 XSLT 中使用 <= 和 >=

转载 作者:行者123 更新时间:2023-12-02 11:57:39 25 4
gpt4 key购买 nike

我想使用<=>=比较 <xsl:if test=""> 中的值时。如何做到这一点?

更新:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>
<body>
<h1>Average classsize per user and module</h1>
<table border="1">

<tr>
<th>User Email</th>
<th>Module Code</th>
<th>Average Value</th>
</tr>
<xsl:apply-templates select="//classsize" />
</table>
</body>
</html>

</xsl:template>

<xsl:template match="average">
<xsl:choose>
<xsl:when test=". &lt; 1">
<td style="background-color: red;"><xsl:value-of select="." /></td>
</xsl:when>

<xsl:when test="1 &lt;= . &lt; 2">
<td style="background-color: blue;"><xsl:value-of select="." /></td>
</xsl:when>

<xsl:when test="2 &lt;= . &lt; 3">
<td style="background-color: yellow;"><xsl:value-of select="." /></td>
</xsl:when>

<xsl:otherwise>
<td style="background-color: white;"><xsl:value-of select="." /></td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="//classsize">
<tr>
<td><xsl:value-of select="email" /></td>
<td><xsl:value-of select="modulecode" /></td>
<xsl:apply-templates select="average" />
</tr>
</xsl:template>

</xsl:stylesheet>
<小时/>
average < 1 - in red
1 <= average < 2 - in blue
2 <= average < 3 - in yellow
average >= 3 - white

最佳答案

您可以逃避 <>&lt;&gt; ,分别。

请参阅 xsl:if 的示例上w3schools .

<小时/>

更新:

看到你的情况后,我对它不起作用并不感到惊讶。

而不是:

1 &lt;= . &lt; 2

尝试:

1 &lt;= . and . &lt; 2

您无法链接 <>就像 XSLT 中的那样。

关于xslt - 在 XSLT 中使用 <= 和 >=,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4312868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com