在XSL FO中操作/访问表数据(Manipulating/accessing table data in XSL FO)

我在XSL FO中制作一个模板来生成一个PDF,它基本上是初始XML文件的格式化版本,我想知道是否可以访问存储在表中特定单元格或单元格集群中的值,例如,如同在excel中那样在表中的值范围内生成总值,或者如果仅限于使用xpath表达式来简单地检索相同的数据并让它直接将结果输出到您想要的单元格。我试过给单元格唯一的id,但是我不明白这是否允许你传递存储在那些单元格中的值。

XML:

<?xml version="1.0" encoding="UTF-8"?> <Numbers> <A>12</A> <B>22</B> <A>19</A> <B>47</B> <A>38</A> <B>2</B> </Numbers>

I am making a template in XSL FO to produce a PDF that is essentially a formatted version of an initial XML file, and i was wondering if it is possible to access the value stored in a specific cell or cluster of cells in a table, for example to produce a total value over a range of values within the table as you would in excel, or if you are limited only to using xpath expressions to simply retrieve the same data and have it directly output the result to the cell you wanted in. I have tried giving the cells unique ids, but i do not understand if this allows you to pass the values stored in those cells or not.

XML:

<?xml version="1.0" encoding="UTF-8"?> <Numbers> <A>12</A> <B>22</B> <A>19</A> <B>47</B> <A>38</A> <B>2</B> </Numbers>

最满意答案

XPath函数:数字和(节点集)

sum(// Numbers / A)...所有A的

sum(// Numbers / B)...所有B的

你也可以使用position()来获得第三个位置到第五个位置......

XPath function: number sum (node-set)

sum(//Numbers/A) ... all the A's

sum(//Numbers/B) ... all the B's

you could also use position() to get things like the third position to the 5th position ...

在XSL FO中操作/访问表数据(Manipulating/accessing table data in XSL FO)

我在XSL FO中制作一个模板来生成一个PDF,它基本上是初始XML文件的格式化版本,我想知道是否可以访问存储在表中特定单元格或单元格集群中的值,例如,如同在excel中那样在表中的值范围内生成总值,或者如果仅限于使用xpath表达式来简单地检索相同的数据并让它直接将结果输出到您想要的单元格。我试过给单元格唯一的id,但是我不明白这是否允许你传递存储在那些单元格中的值。

XML:

<?xml version="1.0" encoding="UTF-8"?> <Numbers> <A>12</A> <B>22</B> <A>19</A> <B>47</B> <A>38</A> <B>2</B> </Numbers>

I am making a template in XSL FO to produce a PDF that is essentially a formatted version of an initial XML file, and i was wondering if it is possible to access the value stored in a specific cell or cluster of cells in a table, for example to produce a total value over a range of values within the table as you would in excel, or if you are limited only to using xpath expressions to simply retrieve the same data and have it directly output the result to the cell you wanted in. I have tried giving the cells unique ids, but i do not understand if this allows you to pass the values stored in those cells or not.

XML:

<?xml version="1.0" encoding="UTF-8"?> <Numbers> <A>12</A> <B>22</B> <A>19</A> <B>47</B> <A>38</A> <B>2</B> </Numbers>

最满意答案

XPath函数:数字和(节点集)

sum(// Numbers / A)...所有A的

sum(// Numbers / B)...所有B的

你也可以使用position()来获得第三个位置到第五个位置......

XPath function: number sum (node-set)

sum(//Numbers/A) ... all the A's

sum(//Numbers/B) ... all the B's

you could also use position() to get things like the third position to the 5th position ...