2016-07-21 37 views
0

我有一个这样的XML:的Apache FOP XSL/XSLT - 使文本生成的PDF大胆

<?xml version="1.0" encoding="UTF-8"?> 
<TermsAndConditions> 
     <clause><clausetext>Terms and Conditions of Supply - Please read carefully</clausetext></clause> 
     <clause><clausetext>Available only to <bold>customers who have an existing</bold> account.</clausetext></clause> 
</TermsAndConditions> 

和样式表是:

<fo:page-sequence master-reference="simple" > 
     <fo:flow flow-name="xsl-region-body">  
     <xsl:for-each select="data/TermsAndConditions/clause"> 
       <fo:block font-size="10pt" font-family="Arial" color="#6d6e71"><xsl:value-of select="clausetext" /> 
</fo:block> 
       <fo:block font-size="10pt" font-family="Arial" line-height="10pt" space-after.optimum="3pt" text-align="justify">&#0160;</fo:block> 
     </xsl:for-each> 
    </fo:flow> 
</fo:page-sequence> 

如何去使文字标签< bold> </bold>在生成的pdf中以粗体显示?目前,我可以看到这些条款,但文本是正常的。

进一步就此,我试着用w3schools.com的tryit编辑器类似的事情: [http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=tryxsl_if]

与下面的样式表:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/"> 
    <html> 
    <body> 
    <xsl:apply-templates mode="tttt" /> 
    </body> 
    </html> 
</xsl:template> 

    <xsl:template match="bold" mode="tttt"> 
    <b><xsl:value-of select="." /></b> 
    </xsl:template> 
</xsl:stylesheet> 

和我得到的输出所需。

+0

告诉你产生hrml样式表。您至少需要使用Apache FOP的XSL FO –

+0

我正在使用xsl fo。第二个样式表是基于第一个样式表作为概念证明。 – user2260040

回答

2

<b>是HTML语法,用于FO这可能应改为:

<xsl:template match="bold" mode="tttt"> 
    <fo:inline font-weight="bold"><xsl:value-of select="." /></fo:inline> 
    </xsl:template> 
</xsl:stylesheet> 
+0

@ user2260040,你没有接受很多答案,这就是所谓的“谢谢”的方式 - 这个答案对你有帮助吗,或者我们能做些什么来帮助你? –