我正在尝试打印一个包含文本和其他节点的节点,但无法将格式应用于子节点。
我有以下 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> </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>
使用此代码,我将打印链接,但未格式化。然后在文本末尾相应地打印所有链接。新行也不会被打印。
尝试
<xsl:template match="text">
<fo:block>
<xsl:apply-templates/>
<xsl:text> </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>