计数< td> xhtml< table>中的元素使用XSLT 1.0 [英] Count <td> Elements in xhtml <table> with XSLT 1.0
本文介绍了计数< td> xhtml< table>中的元素使用XSLT 1.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个XSLT 2.0,可将xhtml表转换为InDesign XML表。此XSLT计算每行< tr> $ c $中
< td>
元素的最大数量 c>下面模板中的第7行( max(对于// tr return count($ td / td)中的$ td c)。
i've an XSLT 2.0 which transforms an xhtml Table into an InDesign XML Table. This XSLT counts the maximum number of <td>
Elements within every row <tr>
Line 7 in the template below (max(for $td in //tr return count($td/td))
).
<xsl:template match="table">
<xsl:element name="id_table">
<xsl:attribute name="aid:trows">
<xsl:value-of select="count(child::*/tr)"/>
</xsl:attribute>
<xsl:attribute name="aid:tcols">
<xsl:value-of select="max(for $td in //tr return count($td/td))"/>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
我不知道如何使用XSLT 1.0实现这一点-任何想法都将不胜感激!可悲的是,工作流管道中只有1.0个处理器。
I've no idea how to realize this with XSLT 1.0 - any ideas would greatly appreciated! Sadly there is only a 1.0 Processor in the Workflow Pipeline.
推荐答案
<xsl:attribute name="aid:tcols">
<xsl:for-each select="//tr">
<xsl:sort select="count(td)" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="count(td)"/>
</xsl:if>
</xsl:for-each>
</xsl:attribute>
应该这样做。
这篇关于计数< td> xhtml< table>中的元素使用XSLT 1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文