XSL 多列切换
XSL Multi Column Switching
我有一个 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>.24</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456790</DialledNumber>
<DateTime>2019-07-15 15:36:35</DateTime>
<Duration>00:04:24</Duration>
<Cost>.25</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456791</DialledNumber>
<DateTime>2019-07-15 15:37:35</DateTime>
<Duration>>00:04:25</Duration>
<Cost>.26</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456792</DialledNumber>
<DateTime>2019-07-15 15:38:35</DateTime>
<Duration>>00:04:26</Duration>
<Cost>.27</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456793</DialledNumber>
<DateTime>2019-07-15 15:39:35</DateTime>
<Duration>>00:04:27</Duration>
<Cost>.28</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456794</DialledNumber>
<DateTime>2019-07-15 15:40:35</DateTime>
<Duration>>00:04:28</Duration>
<Cost>.29</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456795</DialledNumber>
<DateTime>2019-07-15 15:41:35</DateTime>
<Duration>>00:04:29</Duration>
<Cost>.30</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456931</DialledNumber>
<DateTime>2019-07-15 17:57:34</DateTime>
<Duration>00:06:45</Duration>
<Cost>.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>
我想知道是否有人可以帮我显示如下列表
看来你真的只需要知道自己是否少于60CallItem
。如果少于 60,则使 table 跨越两列,如果不是,则使其跨越一列。正常的分页将负责将 table 跨列和跨页拆分。
<xsl:template match="/">
<fo:root xml:lang="en">
<fo:layout-master-set>
<fo:simple-page-master master-name="spm">
<fo:region-body column-count="2" margin="36pt" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="spm">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="CallsMade">
<fo:block span="all">
<xsl:value-of select="@fromNumber" />
</fo:block>
<fo:block-container>
<xsl:if test="count(CallItem) < 60">
<xsl:attribute name="span">all</xsl:attribute>
</xsl:if>
<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:apply-templates select="CallItem" />
</fo:table-body>
</fo:table>
</fo:block-container>
</xsl:template>
<xsl:template match="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:template>
我有一个 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>.24</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456790</DialledNumber>
<DateTime>2019-07-15 15:36:35</DateTime>
<Duration>00:04:24</Duration>
<Cost>.25</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456791</DialledNumber>
<DateTime>2019-07-15 15:37:35</DateTime>
<Duration>>00:04:25</Duration>
<Cost>.26</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456792</DialledNumber>
<DateTime>2019-07-15 15:38:35</DateTime>
<Duration>>00:04:26</Duration>
<Cost>.27</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456793</DialledNumber>
<DateTime>2019-07-15 15:39:35</DateTime>
<Duration>>00:04:27</Duration>
<Cost>.28</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456794</DialledNumber>
<DateTime>2019-07-15 15:40:35</DateTime>
<Duration>>00:04:28</Duration>
<Cost>.29</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456795</DialledNumber>
<DateTime>2019-07-15 15:41:35</DateTime>
<Duration>>00:04:29</Duration>
<Cost>.30</Cost>
</CallItem>
<CallItem>
<DialledNumber>0123456931</DialledNumber>
<DateTime>2019-07-15 17:57:34</DateTime>
<Duration>00:06:45</Duration>
<Cost>.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>
我想知道是否有人可以帮我显示如下列表
看来你真的只需要知道自己是否少于60CallItem
。如果少于 60,则使 table 跨越两列,如果不是,则使其跨越一列。正常的分页将负责将 table 跨列和跨页拆分。
<xsl:template match="/">
<fo:root xml:lang="en">
<fo:layout-master-set>
<fo:simple-page-master master-name="spm">
<fo:region-body column-count="2" margin="36pt" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="spm">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="CallsMade">
<fo:block span="all">
<xsl:value-of select="@fromNumber" />
</fo:block>
<fo:block-container>
<xsl:if test="count(CallItem) < 60">
<xsl:attribute name="span">all</xsl:attribute>
</xsl:if>
<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:apply-templates select="CallItem" />
</fo:table-body>
</fo:table>
</fo:block-container>
</xsl:template>
<xsl:template match="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:template>