admin管理员组文章数量:1122832
I have a working .xsl but I wanted to add a check to see if the current cell is in the first row and first cell:
<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>
I am unable to apply the .xsl with these lines added. If I take them out, it works, so I know that my check isn't correct. Can someone help me with the wordML side. As I approaching this wrong?
Thanks,
Russ
I have a working .xsl but I wanted to add a check to see if the current cell is in the first row and first cell:
<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>
I am unable to apply the .xsl with these lines added. If I take them out, it works, so I know that my check isn't correct. Can someone help me with the wordML side. As I approaching this wrong?
Thanks,
Russ
Share Improve this question asked Nov 22, 2024 at 21:30 Russell Urquhart CRussell Urquhart C 174 bronze badges 3- 1 Please provide a minimal reproducible example showing an example of the input, your current stylesheet and the expected output. – michael.hor257k Commented Nov 22, 2024 at 21:35
- It is a very long .xsl, I'll try and see if I can minimize to something testable. I was really just hoping someone could tell me if the tabel and row WordML commands I was trying to use were correct? – Russell Urquhart C Commented Nov 22, 2024 at 23:09
- 1 Oh, that part is easy: they are not. But in order to fix them we need to see the context. – michael.hor257k Commented Nov 23, 2024 at 1:46
1 Answer
Reset to default 1I am purely guessing you want to do something like:
<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>
Side note:
There is no first()
function in XSLT. XSLT in not an intuitive language. You cannot succeed by trial-and-error.
本文标签:
版权声明:本文标题:xslt - XSL, WordML: Determine if the current cell of a table is in the first row and first column - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300718a1930919.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论