我有一個標籤的xml,其中包含一個屬性,其中的內容爲html。我需要將此html轉換爲xsl-fo。這裏是我的XSLT代碼:Xml內容沒有被模板識別
<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內容。相關的模板不能識別它。
這裏是XML標記與的Html屬性在裏面:
<rtf rtfAsHtml="<div ><p ><span>Hi!</span></p></div>"/>
任何想法如何將這個HTML標記轉換爲XSL-FO?
謝謝!
您的輸入文件是否有任何名稱空間聲明?另外,如果你能夠匹配「rtf」作爲文檔節點,在我看來你的輸入是RTF而不是HTML。 –
@MathiasMüller。不,我的輸入沒有任何命名空間。而且,我的輸入是一個包含從rtf轉換而來的html的xml標籤。但它是HTML。 – Jacob