本文介绍了在 <fo:table-column>number-columns-spanned 与 number-columns-repeated 属性之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,使用 AHFormatter,如果我有这个:

Actually, using AHFormatter, if I have this:

<fo:table-column column-number="2" number-columns-repeated="2" color="red"/>

如果我使用 from-table-column():

<fo:table-cell color="from-table-column()">

然而,

<fo:table-column column-number="2" number-columns-spanned="2" color="red"/>

不能这样工作,所以也许真正的问题是 number-columns-spanned 属性有什么作用,如果有的话?

does not work this way, so maybe the real question is what does the number-columns-spanned attribute of <fo:table-column/> do, if anything?

推荐答案

之前提供的答案,直接复制自 W3C XSL-FO 1.1 规范number-columns-repeated="n" 的作用给出了相当清晰的解释,即它是一个具有相同功能的便利属性效果就像 <fo:table-column/> 格式化对象在结果树中重复了 n 次一样.这对 xhtml <col/> 标记 span 属性进行建模.

The previously provided answer, copied directly from the W3C XSL-FO 1.1 spec gives a fairly clear explanation of what number-columns-repeated="n" does, namely it's a convenience attribute which has the same effect as if the <fo:table-column/> formatting object had been repeated n times in the result tree. This models the xhtml <col/> tag span attribute.

规范中的注释this handles HTML's 'colgroup' element"通常不正确. 可以是 <col/的容器> 标签,并且每个 <col/> 元素都可以提供完全不同的格式属性(除了跨越一列或多列).这种说法只在使用空的 <colgroup> 标签时才是正确的(这是允许的,但令人困惑,因为这相当于只使用 <col> 标签并完全省掉 <colgroup>.xhtml DTD 不允许 允许 <col> 和 <colgroup> 成为兄弟姐妹.你可以使用所有 <col> 元素或所有 <colgroup> 元素(可以有 <col> 子元素,或者使用 span,但不能同时使用两者),或者两者都不使用.

The comment made in the spec that "this handles HTML's 'colgroup" element" is generally incorrect. <colgroup> can be a container for <col/> tags, and each <col/> element can provide completely different formatting attributes (in addition to spanning one or more columns). This statement is only true when using empty <colgroup> tags (which is permissible, but confusing, since this is equivalent to just using <col> tags and dispensing with <colgroup>'s altogether). The xhtml DTD does not allow <col> and <colgroup> to be siblings. You can use all <col> elements or all <colgroup> elements (which can have <col> children, or use span, but not both), or neither.

number-columns-spanned 属性充当附加的 标识符.例如,给定

The number-columns-spanned attribute acts as an additional <table-cell> identifier. For example, given

<fo:table-column column-number="2" color="green" number-columns-spanned="2"/>

如果这两个 都在第二列中:

if both these <table-cell>'s are in the second column:

<fo:table-cell color="from-table-column()">
<fo:table-cell number-columns-spanned="2" color="from-table-column()">

只有第二个表格单元格会用绿色文本呈现.

only the second table-cell would be rendered with green text.

这允许对跨越不同列数的表格单元格进行单独的格式化;例如:

This allows for separate formatting for table-cells spanning a different number of columns; for example:

<fo:table-column column-number="2" color="red"/>
<fo:table-column column-number="2" background-color="lightgray" color="green" number-columns-spanned="2"/>

将提供机会使用 from-table-column() 函数将第二列中任何单列表格单元格中的文本着色为红色,而使用绿色文本为跨第二列和第三列延伸的表格单元格渲染浅灰色背景.

would provide the opportunity to use the from-table-column() function to color the text in any single column table-cells in the second column red, while rendering a lightgray background for table-cells extending across the second and third columns with green text.

有一点混乱.规范中有关于 from-table-column() 的说明:

One point of confusion. The spec has this to say about the from-table-column():

from-table-column 函数从列号匹配的 fo:table-column 返回名称与指定参数匹配的属性的继承值,或者如果为表达式求值的属性省略了该属性的继承值计算此表达式的列,并且其 number-columns-spanned 也与任何跨度匹配.如果 number-columns-spanned 没有匹配项,则匹配一个跨度为 1 的值.如果仍然没有匹配项,则返回初始值.

我觉得这有点令人困惑,所以这里是翻译.假设您的 <fo:table>

I found this somewhat confusing, so here is the translation. Suppose you have only the following <fo:table-column> element in your <fo:table>

<fo:table-column column-number="2" color="red" font-weight="bold"/>

这个 <fo:table-cell> 出现在表格的第二列中:

with this <fo:table-cell> appearing in the second column of your table:

<fo:table-cell number-columns-spanned="2" color="from-table-column()" font-weight="from-table-column()">

格式化程序将检查是否存在带有 number-columns-spanned="2" 的第二列 .没有找到,它将继续使用单列 <fo:table-column> 并将文本呈现为红色和粗体

The formatter will check to see if there if a 2nd column <fo:table-column> with number-columns-spanned="2". Finding none, it will proceed to use the single column <fo:table-column> and will render the text red and bold

这篇关于在 &lt;fo:table-column&gt;number-columns-spanned 与 number-columns-repeated 属性之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:01