我正在使用 xsl 和 pdf 输出。我有一个这样的xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<document>
<header>
<author>my name</author>
</header>
<body>
<text>some text</text>
</body>
</document>
我的 xsl 文件如下所示:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master
master-name="_title"
page-height="29.7cm"
page-width="21cm"
margin="3cm">
<fo:region-body/>
</fo:simple-page-master>
<fo:simple-page-master
master-name="_body"
page-height="29.7cm"
page-width="21cm"
margin="3cm">
<fo:region-body/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="titlepage">
<fo:single-page-master-reference master-reference="_title"/>
</fo:page-sequence-master>
<fo:page-sequence-master master-name="body">
<fo:repeatable-page-master-reference master-reference="_body"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="titlepage">
<fo:flow flow-name="xsl-region-body" font-family="Courier" font-size="12pt">
<fo:block>
<xsl:apply-templates select="header"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="body">
<fo:flow flow-name="xsl-region-body" font-family="Courier" font-size="12pt">
<fo:block>
<xsl:apply-templates select="body"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="header">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="body">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
我希望有两个 pdf 页面,第一页带有“我的名字”,第二页带有“一些文字”。相反,我得到两个空页。