【问题标题】:Transform an HTML DL into 2-column XSL-FO table of terms and definitions将 HTML DL 转换为 2 列 XSL-FO 术语和定义表
【发布时间】:2013-08-28 03:05:26
【问题描述】:

如何使用 XSLT 将 HTML 定义列表 (DL) 转换为双列 XSL-FO 表,其中第一列是术语,第二列是定义,并且可能有多个定义?

(抱歉,如果这已经在某处得到回答。我搜索但没有找到。)

【问题讨论】:

    标签: html xml xslt xsl-fo list-definition


    【解决方案1】:

    这个问题的关键在于找到以下仍然以当前 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-13
      • 2016-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-14
      • 1970-01-01
      • 2012-03-15
      相关资源
      最近更新 更多