如何在xml中使用xsl标记



HelloAll,

我想在下面的代码中使用<xsl:variable name="vPageNumber"><fo:page-number /></xsl:variable>,但编辑器给了我一个响应,例如javax.xml.transform.TransformerException:org.xml.sax.SAXParseException;前缀";xsl"对于元素";xsl:variable"未绑定我能做什么?

<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:static-content flow-name="page-header">
<fo:table border="solid">
<fo:table-column column-width="20%"/>
<fo:table-column column-width="67%"/>
<fo:table-column column-width="13%"/>
<fo:table-body>
<fo:table-row >
<fo:table-cell>
<fo:block padding-right="15px" padding-bottom="2mm" padding-top="1mm">
<fo:block text-align="right" margin-right="24px"   > 
<fo:external-graphic content-width="20mm"  src="url(D:/Atlassian/images/Turkak.gif)" />
</fo:block>
<fo:table width="20mm" height="24mm" font-size="7pt" >
<fo:table-row border="solid" height="8mm">
<fo:table-cell>
<fo:block text-align="center" padding="3mm" > 
AB-1365-T
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="solid" height="8mm" >
<fo:table-cell>
<fo:block text-align="center" padding="3mm">$xmlutils.escape($issue.key)</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="solid" height="8mm" >
<fo:table-cell>
<fo:block text-align="center" padding="3mm"> $date.format("MM-yy", $issue.getCustomFieldValue("customfield_17843"))</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>

您不能在XSL阶段使用未知信息。页码只有在合成阶段才知道,而不是在转换为XSL FO时才知道

您只能考虑对FO处理器的中间格式进行组合,然后对其应用新的转换以使用数据。

在您的示例中,您没有提供任何信息说明为什么需要将其作为变量。如果你只想打印它,那么你应该只使用fo:页码。

如果定义:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" font-family="auto">

您可以在代码中使用XSL标记。

最新更新