我有很多XSL文件,它们有一个共同的部分。我想将此部分与另一个XSL文件分开并将其包含在每个文件中(以便只能对其应用一次更改)。我正在使用Apache FOP从XSL文件创建PDF。我已经尝试过这里描述的方法:How to use `xsl:include` with apache fop,但没有成功。
以下是XSL的一部分:
<xsl:template match="fooBar">
<fo:root xmlns:fo="__http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
....
....
<!-- Parent element of the part, I want to separate -->
<fo:page-sequence master-reference="pages">
<!-- This is the part, I want to move to separate XSL file -->
<fo:static-content flow-name="page-footer">
<fo:block font-size="7pt" margin-left="10mm">
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="100%"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>Some text which will be changed</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:static-content>
<!-- This is the part, I want to move to separate XSL file -->
当我将部件放置在单独的XSL文件中时,我得到了Apache FOP的错误。
SystemId未知; (包括的行和列); org.xml.sax.SAXException:ElemTemplateElement错误:&#34;模板名称&#34; javax.xml.transform.TransformerException:ElemTemplateElement错误:&#34;模板名称&#34; SystemId未知; (包括的行和列);找不到名为的模板:&#34;模板名称&#34;
我尝试了这种方式:
<xsl:include href="templateFileName.xsl"/> (To the header)
<xsl:call-template name="templateFileName"/> (Directly on wanted place)
<xsl:apply-templates select="templateFileName"/> (Directly on wanted place)
他们都没有工作。
PDF已创建,但没有此部分。如果需要,我很乐意提供更多信息/细节。
感谢您的任何建议!