Xslt XSL:在两列中对每个列进行筛选

Xslt XSL:在两列中对每个列进行筛选,xslt,xslt-1.0,xsl-fo,Xslt,Xslt 1.0,Xsl Fo,我正在使用一个程序生成报告。该程序使用XSL文件生成PDF报告。我正在尝试创建一个自定义XSL文件 在我的示例中,我尝试只为3.5英寸软盘或5.25英寸软盘(单独)的项生成报告。除此之外,我还尝试将结果放入每个索引卡的两列中,以便打印 我不是XSL专家,但我做了一项研究,找到了几种可能的解决方案来实现我的目标(主要是),但是最终的结果总是不是我想要的——我可能对XSL部分有错误的概念,我希望有任何输入/指针 这里是XML的一部分: ?xml version="1.0" encoding="UTF

我正在使用一个程序生成报告。该程序使用XSL文件生成PDF报告。我正在尝试创建一个自定义XSL文件

在我的示例中,我尝试只为3.5英寸软盘或5.25英寸软盘(单独)的项生成报告。除此之外,我还尝试将结果放入每个索引卡的两列中,以便打印

我不是XSL专家,但我做了一项研究,找到了几种可能的解决方案来实现我的目标(主要是),但是最终的结果总是不是我想要的——我可能对XSL部分有错误的概念,我希望有任何输入/指针

这里是XML的一部分:

?xml version="1.0" encoding="UTF-8" ?>
<catalog-objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="temp.xsd">
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 1</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 2</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 3</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>CD-Rom</name>
            </storage-medium>
        </media-types>
        <title>Title 4</title>
    </software-item>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    exclude-result-prefixes="fo">
    <xsl:import href="../../_stylesheets/pdf_desert.xsl" />
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" />
    <xsl:param name="versionParam" select="'1.0'" />
    <xsl:template match="/">
        <xsl:param name="size" select="count(catalog-objects/software-item)"/>
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Index Card 4X6"
                    page-height="4in" page-width="6in" margin-top="4mm"
                    margin-bottom=".65in" margin-left="4mm" margin-right="4mm">
                    <fo:region-body />
                    <fo:region-after />
                </fo:simple-page-master>
            </fo:layout-master-set>
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[(contains(media-types, '5.25') and not(contains(media-types, '3.5') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray'))) or (contains(media-types, '3.5') and not(contains(media-types, '5.25') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray')))]" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies[ceiling($size div 2) &gt;= position()]">
                <fo:page-sequence master-reference="Index Card 4X6">
                    <fo:static-content flow-name="xsl-region-after">
                        <fo:block font-size="{$fontSize}">
                        </fo:block>
                    </fo:static-content>

                    <fo:flow flow-name="xsl-region-body">
                        <fo:block font-size="{$fontSize}">
                            <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                <fo:table-column column-width="45%" />
                                <fo:table-column column-width="45%" />
                                <fo:table-body>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(following::software-item[ceiling($size div 2)]/archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="title" />
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="following::software-item[ceiling($size div 2)]/title" />
                                                </fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
╔════════════╤════════════╗ ║ Title 1 │ Title 2 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 1: ╔════════════╤════════════╗ ║ Title 1 │ Title 3 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 2: ╔════════════╤════════════╗ ║ Title 2 │ Title 4 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[normalize-space(media-types)='3.5&quot; Floppy' or normalize-space(media-types)='5.25&quot; Floppy']" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies">
            <xsl:variable name="pos" select="position()" />
                <xsl:if test="position() mod 2 = 1">
                    <fo:page-sequence master-reference="Index Card 4X6">
                        <fo:static-content flow-name="xsl-region-after">
                            <fo:block font-size="{$fontSize}">
                            </fo:block>
                        </fo:static-content>
    <!--Table Begins-->
                        <fo:flow flow-name="xsl-region-body">
                            <fo:block font-size="{$fontSize}">
                                <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-body>
                                            <fo:table-row>
                                                <fo:table-cell number-columns-spanned="3">
                                                        <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                                </fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell number-columns-spanned="3">
                                                            <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number($individualFloppies[$pos+1]/archive-id, "000000")' /></fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                <xsl:otherwise>
                                                    <fo:table-cell number-columns-spanned="3"><fo:block></fo:block></fo:table-cell>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            </fo:table-row>
                                            <fo:table-row>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell border-bottom="1px solid #000000">
                                                    <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                        <xsl:value-of select="title" />
                                                    </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell border-bottom="1px solid #000000">
                                                            <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                                <xsl:value-of select="$individualFloppies[$pos+1]/title" />
                                                            </fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                            </fo:table-row>
生成报告后得到的是两页:

?xml version="1.0" encoding="UTF-8" ?>
<catalog-objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="temp.xsd">
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 1</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 2</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 3</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>CD-Rom</name>
            </storage-medium>
        </media-types>
        <title>Title 4</title>
    </software-item>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    exclude-result-prefixes="fo">
    <xsl:import href="../../_stylesheets/pdf_desert.xsl" />
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" />
    <xsl:param name="versionParam" select="'1.0'" />
    <xsl:template match="/">
        <xsl:param name="size" select="count(catalog-objects/software-item)"/>
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Index Card 4X6"
                    page-height="4in" page-width="6in" margin-top="4mm"
                    margin-bottom=".65in" margin-left="4mm" margin-right="4mm">
                    <fo:region-body />
                    <fo:region-after />
                </fo:simple-page-master>
            </fo:layout-master-set>
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[(contains(media-types, '5.25') and not(contains(media-types, '3.5') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray'))) or (contains(media-types, '3.5') and not(contains(media-types, '5.25') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray')))]" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies[ceiling($size div 2) &gt;= position()]">
                <fo:page-sequence master-reference="Index Card 4X6">
                    <fo:static-content flow-name="xsl-region-after">
                        <fo:block font-size="{$fontSize}">
                        </fo:block>
                    </fo:static-content>

                    <fo:flow flow-name="xsl-region-body">
                        <fo:block font-size="{$fontSize}">
                            <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                <fo:table-column column-width="45%" />
                                <fo:table-column column-width="45%" />
                                <fo:table-body>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(following::software-item[ceiling($size div 2)]/archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="title" />
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="following::software-item[ceiling($size div 2)]/title" />
                                                </fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
╔════════════╤════════════╗ ║ Title 1 │ Title 2 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 1: ╔════════════╤════════════╗ ║ Title 1 │ Title 3 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 2: ╔════════════╤════════════╗ ║ Title 2 │ Title 4 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[normalize-space(media-types)='3.5&quot; Floppy' or normalize-space(media-types)='5.25&quot; Floppy']" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies">
            <xsl:variable name="pos" select="position()" />
                <xsl:if test="position() mod 2 = 1">
                    <fo:page-sequence master-reference="Index Card 4X6">
                        <fo:static-content flow-name="xsl-region-after">
                            <fo:block font-size="{$fontSize}">
                            </fo:block>
                        </fo:static-content>
    <!--Table Begins-->
                        <fo:flow flow-name="xsl-region-body">
                            <fo:block font-size="{$fontSize}">
                                <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-body>
                                            <fo:table-row>
                                                <fo:table-cell number-columns-spanned="3">
                                                        <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                                </fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell number-columns-spanned="3">
                                                            <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number($individualFloppies[$pos+1]/archive-id, "000000")' /></fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                <xsl:otherwise>
                                                    <fo:table-cell number-columns-spanned="3"><fo:block></fo:block></fo:table-cell>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            </fo:table-row>
                                            <fo:table-row>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell border-bottom="1px solid #000000">
                                                    <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                        <xsl:value-of select="title" />
                                                    </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell border-bottom="1px solid #000000">
                                                            <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                                <xsl:value-of select="$individualFloppies[$pos+1]/title" />
                                                            </fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                            </fo:table-row>
第1页: ╔════════════╤════════════╗ ║ 标题1│ 标题3║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ 第2页: ╔════════════╤════════════╗ ║ 标题2│ 标题4║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ 要把逻辑写下来: 由于“标题1”仅为“5.25”软盘,而“标题2”仅为“3.5”软盘,因此它们是唯一应该显示的两个。 “Title 3”是“5.25软盘”,但也是“3.5软盘”,因此不应显示。 “Title 4”是一个“CD-Rom”,因此不应显示为列

写这篇文章让我意识到我使用的过滤器不起作用——考虑到我在不同方面使用了一些类似的过滤器,它确实起作用


我希望这些编辑是预期中的“示例”,它们能进一步澄清问题。

AFAICT,这里的问题在于表达式:

<xsl:value-of select="following::software-item[ceiling($size div 2)]/title" />

在michael.hor257k的帮助下(再次感谢!)我成功地添加和更改了必要的代码行,以便生成我想要的报告

以下是更新后的代码(从应用第一次更改的位置开始):

?xml version="1.0" encoding="UTF-8" ?>
<catalog-objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="temp.xsd">
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 1</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 2</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 3</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>CD-Rom</name>
            </storage-medium>
        </media-types>
        <title>Title 4</title>
    </software-item>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    exclude-result-prefixes="fo">
    <xsl:import href="../../_stylesheets/pdf_desert.xsl" />
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" />
    <xsl:param name="versionParam" select="'1.0'" />
    <xsl:template match="/">
        <xsl:param name="size" select="count(catalog-objects/software-item)"/>
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Index Card 4X6"
                    page-height="4in" page-width="6in" margin-top="4mm"
                    margin-bottom=".65in" margin-left="4mm" margin-right="4mm">
                    <fo:region-body />
                    <fo:region-after />
                </fo:simple-page-master>
            </fo:layout-master-set>
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[(contains(media-types, '5.25') and not(contains(media-types, '3.5') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray'))) or (contains(media-types, '3.5') and not(contains(media-types, '5.25') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray')))]" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies[ceiling($size div 2) &gt;= position()]">
                <fo:page-sequence master-reference="Index Card 4X6">
                    <fo:static-content flow-name="xsl-region-after">
                        <fo:block font-size="{$fontSize}">
                        </fo:block>
                    </fo:static-content>

                    <fo:flow flow-name="xsl-region-body">
                        <fo:block font-size="{$fontSize}">
                            <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                <fo:table-column column-width="45%" />
                                <fo:table-column column-width="45%" />
                                <fo:table-body>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(following::software-item[ceiling($size div 2)]/archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="title" />
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="following::software-item[ceiling($size div 2)]/title" />
                                                </fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
╔════════════╤════════════╗ ║ Title 1 │ Title 2 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 1: ╔════════════╤════════════╗ ║ Title 1 │ Title 3 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 2: ╔════════════╤════════════╗ ║ Title 2 │ Title 4 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[normalize-space(media-types)='3.5&quot; Floppy' or normalize-space(media-types)='5.25&quot; Floppy']" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies">
            <xsl:variable name="pos" select="position()" />
                <xsl:if test="position() mod 2 = 1">
                    <fo:page-sequence master-reference="Index Card 4X6">
                        <fo:static-content flow-name="xsl-region-after">
                            <fo:block font-size="{$fontSize}">
                            </fo:block>
                        </fo:static-content>
    <!--Table Begins-->
                        <fo:flow flow-name="xsl-region-body">
                            <fo:block font-size="{$fontSize}">
                                <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-body>
                                            <fo:table-row>
                                                <fo:table-cell number-columns-spanned="3">
                                                        <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                                </fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell number-columns-spanned="3">
                                                            <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number($individualFloppies[$pos+1]/archive-id, "000000")' /></fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                <xsl:otherwise>
                                                    <fo:table-cell number-columns-spanned="3"><fo:block></fo:block></fo:table-cell>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            </fo:table-row>
                                            <fo:table-row>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell border-bottom="1px solid #000000">
                                                    <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                        <xsl:value-of select="title" />
                                                    </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell border-bottom="1px solid #000000">
                                                            <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                                <xsl:value-of select="$individualFloppies[$pos+1]/title" />
                                                            </fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                            </fo:table-row>

身份证件
身份证件
指出更新的行:

?xml version="1.0" encoding="UTF-8" ?>
<catalog-objects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="temp.xsd">
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 1</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 2</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>3.5&quot; Floppy</name>
            </storage-medium>
            <storage-medium>
                <name>5.25&quot; Floppy</name>
            </storage-medium>
        </media-types>
        <title>Title 3</title>
    </software-item>
    <software-item>
        <item>Software</item>
        <media-types>
            <storage-medium>
                <name>CD-Rom</name>
            </storage-medium>
        </media-types>
        <title>Title 4</title>
    </software-item>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    exclude-result-prefixes="fo">
    <xsl:import href="../../_stylesheets/pdf_desert.xsl" />
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" />
    <xsl:param name="versionParam" select="'1.0'" />
    <xsl:template match="/">
        <xsl:param name="size" select="count(catalog-objects/software-item)"/>
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Index Card 4X6"
                    page-height="4in" page-width="6in" margin-top="4mm"
                    margin-bottom=".65in" margin-left="4mm" margin-right="4mm">
                    <fo:region-body />
                    <fo:region-after />
                </fo:simple-page-master>
            </fo:layout-master-set>
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[(contains(media-types, '5.25') and not(contains(media-types, '3.5') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray'))) or (contains(media-types, '3.5') and not(contains(media-types, '5.25') or contains(media-types, 'ROM') or contains(media-types, 'Disc') or contains(media-types, 'CD') or contains(media-types, 'DVD') or contains(media-types, 'ray')))]" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies[ceiling($size div 2) &gt;= position()]">
                <fo:page-sequence master-reference="Index Card 4X6">
                    <fo:static-content flow-name="xsl-region-after">
                        <fo:block font-size="{$fontSize}">
                        </fo:block>
                    </fo:static-content>

                    <fo:flow flow-name="xsl-region-body">
                        <fo:block font-size="{$fontSize}">
                            <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                <fo:table-column column-width="45%" />
                                <fo:table-column column-width="45%" />
                                <fo:table-body>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                    <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(following::software-item[ceiling($size div 2)]/archive-id, "000000")' /></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="title" />
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell border-bottom="1px solid #000000">
                                                <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                    <xsl:value-of select="following::software-item[ceiling($size div 2)]/title" />
                                                </fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
╔════════════╤════════════╗ ║ Title 1 │ Title 2 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 1: ╔════════════╤════════════╗ ║ Title 1 │ Title 3 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝ PAGE 2: ╔════════════╤════════════╗ ║ Title 2 │ Title 4 ║ ╠════════════╪════════════╣ ║ │ ║ ║ │ ║ ║ │ ║ ╚════════════╧════════════╝
            <xsl:variable name="individualFloppies" select="catalog-objects/software-item[normalize-space(media-types)='3.5&quot; Floppy' or normalize-space(media-types)='5.25&quot; Floppy']" />
            <xsl:param name="size" select="$individualFloppies"/>
            <xsl:for-each select="$individualFloppies">
            <xsl:variable name="pos" select="position()" />
                <xsl:if test="position() mod 2 = 1">
                    <fo:page-sequence master-reference="Index Card 4X6">
                        <fo:static-content flow-name="xsl-region-after">
                            <fo:block font-size="{$fontSize}">
                            </fo:block>
                        </fo:static-content>
    <!--Table Begins-->
                        <fo:flow flow-name="xsl-region-body">
                            <fo:block font-size="{$fontSize}">
                                <fo:table table-layout="fixed" width="100%" border-collapse="collapse">
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-column column-width="45%" />
                                    <fo:table-column column-width="2.5%" />
                                    <fo:table-body>
                                            <fo:table-row>
                                                <fo:table-cell number-columns-spanned="3">
                                                        <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number(archive-id, "000000")' /></fo:block>
                                                </fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell number-columns-spanned="3">
                                                            <fo:block text-align="right" font-size="8"><fo:inline font-weight="bold">ID </fo:inline><xsl:value-of select='format-number($individualFloppies[$pos+1]/archive-id, "000000")' /></fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                <xsl:otherwise>
                                                    <fo:table-cell number-columns-spanned="3"><fo:block></fo:block></fo:table-cell>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            </fo:table-row>
                                            <fo:table-row>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell border-bottom="1px solid #000000">
                                                    <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                        <xsl:value-of select="title" />
                                                    </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                <xsl:choose>
                                                    <xsl:when test="position() != last()">
                                                        <fo:table-cell border-bottom="1px solid #000000">
                                                            <fo:block text-align="center" padding-top="0.2in" font-size="12" font-weight="bold">
                                                                <xsl:value-of select="$individualFloppies[$pos+1]/title" />
                                                            </fo:block>
                                                        </fo:table-cell>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                                <fo:table-cell><fo:block></fo:block></fo:table-cell>
                                            </fo:table-row>
第1行:更干净,我相信这是将数据过滤到变量中的更好方法

第3-4行:实现michael.hor257k示例的第一部分

第5行:使循环仅在奇数节点上工作(不确定我的术语是否正确)


第26-35/46-57行:执行michael.hor257k示例的第二部分,并检查当前位置是否是最后一个位置。

您能否发布所需输出的示例,并指出它与您当前获得的不同之处?输出示例将非常有用。同时,请看一看:您在数据中留下了8英寸软盘。感谢您的回答。您的示例非常好,为我指明了正确的方向!我不确定这是否可以接受,但我将使用您的示例提供(作为回答)我测试过的完整代码