【发布时间】:2016-07-21 22:38:58
【问题描述】:
我有一个这样的 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"> </fo:block>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
如何在生成的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>
我得到了想要的输出。
【问题讨论】:
-
您显示的样式表会生成 hrml。您至少需要使用 XSL FO for Apache FOP
-
我正在使用 xsl fo。第二个样式表基于第一个样式表,只是作为概念证明。
标签: xml apache xslt apache-fop