Apache FOP XSL/XSLT-在生成的PDF中加粗文本



我有一个这样的xml:

<?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中显示为bold?目前,我可以看到条款,但文本都很正常。

除此之外,我还使用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>

我得到了想要的输出。

<b>是html语法,对于fo,这可能应该是:

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

最新更新