我有一个工作 .xsl,但我想添加一个检查以查看当前单元格是否位于第一行和第一个单元格中:
<xsl:for-each select="w:tr">
<xsl:for-each select="w:tc[position()!=last()]">
<!-- Check if first row and if is first column -->
<xsl:if test="w:tr[position()=first()] and w:tc[position()=first()]">
<xsl:text>\mcx</xsl:text>
</xsl:if>
<!-- Check if is first row only -->
<xsl:if test="w:tr[position()=first()] and w:tc[position()!=first()]">
<xsl:text>\mc</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
我无法应用添加了这些行的 .xsl。如果我把它们拿出来,它就会起作用,所以我知道我的支票不正确。有人可以帮我解决 wordML 方面的问题吗?当我接近这个错误时?
谢谢,
拉斯
我纯粹猜测你想做类似的事情:
<xsl:for-each select="w:tr">
<xsl:variable name="is1stRow" select="position()=1" />
<xsl:for-each select="w:tc">
<xsl:choose>
<xsl:when test="$is1stRow and position()=1">
<!-- this is the first cell in the first row -->
<xsl:text>\mcx</xsl:text>
</xsl:when>
<xsl:when test="$is1stRow">
<!-- this is another cell in the first row -->
<xsl:text>\mc</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- this is a cell in another row -->
<!-- do something here? -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>