【发布时间】:2013-11-25 14:35:57
【问题描述】:
我有一个带有标签的 xml,其中包含一个带有 html 内容的属性。我需要将此 html 转换为 xsl-fo 。这是我的 xslt 代码:
<xsl:template match ="rtf">
<fo:block-container>
<fo:block>
<xsl:call-template name ="ConvertHtmlToXslfo">
<xsl:with-param name ="content">
<xsl:value-of select ="@rtfAsHtml" disable-output-escaping ="yes"/>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:block-container>
</xsl:template>
<xsl:template name="ConvertHtmlToXslfo">
<xsl:param name ="content"></xsl:param>
<fo:block-container>
<xsl:apply-templates select="msxsl:node-set($content)"/> <!--here is the problem-->
</fo:block-container>
</xsl:template>
<xsl:template match ="div">
<fo:block-container>
<!--more code here-->
</fo:block-container>
</xsl:template>
<xsl:template match ="p">
<fo:block>
<!--more code here-->
</fo:block>
</xsl:template>
<xsl:template match ="span">
<fo:inline>
<!--more code here-->
</fo:inline>
</xsl:template>
但是有一个问题,当在这个 html 内容上调用 apply-templates 时。相关模板无法识别。
这是带有 Html 属性的 xml 标签:
<rtf rtfAsHtml="<div ><p ><span>Hi!</span></p></div>"/>
知道如何将此 Html 标签转换为 xsl-fo 吗?
谢谢!
【问题讨论】:
-
您的输入文件是否有任何命名空间声明?此外,如果您能够将“rtf”匹配为文档节点,那么在我看来,您的输入是 RTF 而不是 HTML。
-
@MathiasMüller。不,我的输入没有任何命名空间。而且,我的输入是一个 xml 标记,其中包含从 rtf 转换的 html。但它是html。