使用 XSL FO 格式化文本节点内的节点

问题描述 投票:0回答:1

我正在尝试打印一个包含文本和其他节点的节点,但无法将格式应用于子节点。

我有以下 xml:

    <text>Lorem Ipsum is simply dummy <link>text of the printing</link> and typesetting
 industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. </text>

我需要按顺序显示文本并设置链接格式。我还想在文本末尾添加新行。

这是我的xsl:

<xsl:template match="text">
        <xsl:value-of select="."/>
        <xsl:apply-templates select="link"/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

    <xsl:template match="link">
        <fo:basic-link color="red" text-decoration="underline" external-destination="{whatever}">
            <xsl:value-of select="whatever"/>
        </fo:basic-link>
    </xsl:template>

使用此代码,我将打印链接,但未格式化。然后在文本末尾相应地打印所有链接。新行也不会被打印。

xml xslt xsl-fo
1个回答
1
投票

尝试

<xsl:template match="text">
  <fo:block>
        <xsl:apply-templates/>
        <xsl:text>&#10;</xsl:text>
  </fo:block>
</xsl:template>

<xsl:template match="link">
    <fo:basic-link color="red" text-decoration="underline" external-destination="{whatever}">
        <xsl:value-of select="whatever"/>
    </fo:basic-link>
</xsl:template>
© www.soinside.com 2019 - 2024. All rights reserved.