【发布时间】:2019-07-15 19:50:15
【问题描述】:
我有一个 xml,其中列出了客户拨打的电话,我需要在两列中显示。根据调用次数,列表可以是单页 - 单列、单页 - 双列或多页 - 双列。
我必须使用基本的 apace fop,并且无法访问天线屋或类似的库。
当我使用 for-each 时,我可以显示调用,但只能显示在单个列上。我一辈子都做不到双栏目。
我最接近的是@Eliot Kimber 下面的这个视频,但就是无法做到这一点
https://www.youtube.com/watch?v=x6pe7KXicpA
我尝试使用列 mod,但再次将所有调用都列在一个列中
我的 XML 如下所示。
<CallsMade fromNumber="987654321">
<CallItem>
<DialledNumber>0123456789</DialledNumber>
<DateTime>2019-07-15 15:35:35</DateTime>
<Duration>00:04:23</Duration>
<Cost>$1.24</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456790</DialledNumber>
<DateTime>2019-07-15 15:36:35</DateTime>
<Duration>00:04:24</Duration>
<Cost>$1.25</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456791</DialledNumber>
<DateTime>2019-07-15 15:37:35</DateTime>
<Duration>>00:04:25</Duration>
<Cost>$1.26</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456792</DialledNumber>
<DateTime>2019-07-15 15:38:35</DateTime>
<Duration>>00:04:26</Duration>
<Cost>$1.27</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456793</DialledNumber>
<DateTime>2019-07-15 15:39:35</DateTime>
<Duration>>00:04:27</Duration>
<Cost>$1.28</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456794</DialledNumber>
<DateTime>2019-07-15 15:40:35</DateTime>
<Duration>>00:04:28</Duration>
<Cost>$1.29</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456795</DialledNumber>
<DateTime>2019-07-15 15:41:35</DateTime>
<Duration>>00:04:29</Duration>
<Cost>$1.30</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456931</DialledNumber>
<DateTime>2019-07-15 17:57:34</DateTime>
<Duration>00:06:45</Duration>
<Cost>$2.66</Cost>
</CallItem>
<CallsMade>`
XSL 多页,但单列在下面
<fo:block-container start-indent="0mm" left="5mm" width="48%" span="all">
<fo:table table-layout="fixed" width="100%" font-size="5pt" text-align="center" display-align="center" span="all">
<fo:table-column column-width="proportional-column-width(10)"/>
<fo:table-column column-width="proportional-column-width(15)"/>
<fo:table-column column-width="proportional-column-width(12)"/>
<fo:table-column column-width="proportional-column-width(8)"/>
<fo:table-body font-size="95%" >
<xsl:for-each select="CallItem">
<fo:table-row height="4mm" text-align="center" display-align="center">
<fo:table-cell>
<fo:block>
<xsl:value-of select="DialledNumber"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="DateTime"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Duration"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="Cost"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block-container>
我想知道是否有人可以帮我显示如下列表
【问题讨论】:
-
"根据调用次数的不同,列表可以是单页-单列、单页-双列或多页-双列":您是否知道该数字的值您希望 XSLT 在哪个位置生成不同的 FO 结果?
-
谢谢马丁。第一页有另一个块,可以是 1-n 行。一个页面最多可以有 60 行,所以 60 行之后,下一列……120 次之后调用下一页……
-
我的 FO 不好,但是对于 XSLT,如果您能够更改它并且可以使用 XSLT 2(在 Java 世界中使用 Saxon 9 很容易),您可以简单地使用位置分组将每个 60 行的块包装到自己的容器中,如果您有多个块,则切换
span属性。我在xsltfiddle.liberty-development.net/bFN1ya7/3 和xsltfiddle.liberty-development.net/bFN1ya7/4 尝试了一些示例,它们使用低于60 的值来试验您的测试数据。您可能想为 XSL-FO 添加一个标签,以便在 FO 方面获得更多知识渊博的帮助。 -
如果你之前已经跨越了一些东西并且不知道它们将在哪里结束,因此不知道你的表将从哪里开始(以及根据定义有多少适合),那么你不能在没有格式化程序的情况下执行此操作,除非它们支持像 RenderX 的 flow-section 这样的扩展,您可以在其中将多列放入其他流中。
标签: java xml xslt xsl-fo apache-fop