0
我尝试使用Apache FOP创建PDF文件。许多事情工作得很好,但我不能成功使用嵌套标签。名称“Doe”不以粗体字显示。 非常感谢嵌套标签无法正常工作的xsl fo
这里是我的数据和XSL-FO文件:
数据
<?xml version="1.0" encoding="UTF-8"?>
<patient>
<name>Joe <bold>Doe</bold></name>
</patient>
文件
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="patient">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="introA4" page-height="29.7cm" page-width="21cm" margin-top="7cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="introA4">
<fo:flow flow-name="xsl-region-body" color="#808285">
<fo:block font-size="16pt" space-after="0mm">
<xsl:value-of select="name"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="bold">
<fo:inline font-weight="bold" color="red">
<!--xsl:apply-templates select="node()"/-->
<!--xsl:apply-templates select="patient/bold"/-->
<xsl:apply-templates/>
<!--xsl:value-of select="bold"/-->
</fo:inline>
</xsl:template>
<xsl:template match="boldGold">
<fo:inline font-family="OpenSans-ExtraBold" font-weight="bold" color="red">
<xsl:value-of select="boldGold"/>
</fo:inline>
</xsl:template>
</xsl:stylesheet>
谢谢您的回答。它完美地工作,替代解决方案是伟大的。再次感谢! –