1
如何使用XSLT将HTML定义列表(DL)转换为具有第一列中的术语的两列XSL-FO表,第二种定义可能有多种定义?将HTML DL转换为术语和定义的2列XSL-FO表
(。道歉,如果这已经是地方我回答搜查,但没有找到)
如何使用XSLT将HTML定义列表(DL)转换为具有第一列中的术语的两列XSL-FO表,第二种定义可能有多种定义?将HTML DL转换为术语和定义的2列XSL-FO表
(。道歉,如果这已经是地方我回答搜查,但没有找到)
这个问题有发现以下兄弟姐妹的症结仍然有当前DT作为其任期: XSLT: Select following-sibling until reaching a specified tag
然后,只需将整个表格定义为顶级DL模板即可:
<xsl:template match="dl">
<fo:table>
<fo:table-body>
<xsl:for-each select="dt">
<xsl:variable name="current-term" select="."/>
<fo:table-row>
<fo:table-cell font-weight="bold" width="5.5cm">
<fo:block>
<xsl:apply-templates />
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:apply-templates select="following-sibling::dd[preceding-sibling::dt[1] = $current-term]" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="dd">
<fo:block>
<xsl:apply-templates />
</fo:block>
</xsl:template>