Xslt XSL-fo动态创建表
我需要通过调用XSL:FO中的模板在中创建一个表 例如。 我希望调用一个模板函数 表格模板Xslt XSL-fo动态创建表,xslt,xsl-fo,Xslt,Xsl Fo,我需要通过调用XSL:FO中的模板在中创建一个表 例如。 我希望调用一个模板函数 表格模板 <xsl:template name="getTable"> <xsl:template name="getCell"> 使用fo:table标记创建表,并调用列模板,并为列数传递一个参数 创建fo:body标记并调用row模板,并将行数作为参数传递 </xsl:template> 列模板例如 <xsl:template name="getcolu
<xsl:template name="getTable">
<xsl:template name="getCell">
使用fo:table标记创建表,并调用列模板,并为列数传递一个参数
创建fo:body标记并调用row模板,并将行数作为参数传递
</xsl:template>
列模板例如
<xsl:template name="getcolumn">
</xsl:template>
Row template
行模板
调用单元格模板并传递“单元格数”参数
</xsl:template>
单元格模板
<xsl:template name="getTable">
<xsl:template name="getCell">
调用另一个模板
</xsl:template>
我已经用XSL:FO创建了一个表。我可以通过下面的表在XSL:fo中创建表,但我希望创建一个表,因为我需要根据输入多次复制它
<fo:table xsl:use-attribute-sets="Table" >
<fo:table-column />
<fo:table-column />
<fo:table-body>
<fo:table-row >
<fo:table-cell >
<fo:block xsl:use-attribute-sets="JobTaskHeaderBackground">
School1
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:call-template name="Required">
<xsl:with-param name="ElementToCheck" select='m:SchoolName' />
</xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
学校一
我需要根据参数多次复制它
e、 g.(NoOfTables)参数=2
您可以递归调用模板本身,例如:
<xsl:template name="generate-tables">
<xsl:param name="number-of-tables"/>
<xsl:param name="number-of-rows"/>
<xsl:param name="number-of-columns"/>
<xsl:if test="$number-of-tables > 1">
<!-- code to generate a table -->
<!-- recursive call -->
<xsl:call-template name="generate-tables">
<xsl:call-template name="repeat">
<xsl:with-param name="number-of-tables" select="$number-of-tables - 1"/>
<xsl:with-param name="number-of-rows" select="$number-of-rows"/>
<xsl:with-param name="number-of-columns" select="$number-of-columns"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
这是假设您希望所有生成的表具有相同的行数和列数。仍然不清楚您打算如何填充多个表-假设您不希望它们具有相同的数据。XSLT中的这些点不允许使用您的
xsl:with param
。Tony您是对的,这是输入错误,我已经附上了它在调用模板标记内。感谢Michael的回复,但是我如何传递参数以动态获取“m:SchoolName”值(在单元格模板内)。学校名称是从所需的另一个模板中获取的。@user1339913我恐怕不知道这指的是什么。你需要编辑你的问题并提供一个答案。