我有一个具有相同标签的循环来加载十个单元格中的内容,但有不同的 div 标题和背景图像,所以我想知道有什么方法可以使用 switch case 只是在我执行 for-each 加载时放置正确的 div 标题XSL 中每个单元格的内容?像这样的东西:<...在此处加载相同的标签内容...>请帮助我,因为我是新手XSL,无论如何谢谢您!

有帮助吗?

解决方案

您可以使用 if 条件

<xsl:if test="expression">
  ...some output if the expression is true...
</xsl:if>

或者选择,如果有多个条件需要检查

<xsl:choose>
  <xsl:when test="expression">
    ... some output ...
  </xsl:when>
  <xsl:when test="another expression">
    ... some output ...
  </xsl:when>
  <xsl:otherwise>
    ... some output ....
  </xsl:otherwise>
</xsl:choose>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top