.fo创建的PDF文件不符合预期

时间:2012-12-23 23:08:32

标签: xslt xsl-fo

我有一个输出XSL-FO的XSLT样式表,用于生成PDF文件。我正在返回本周的预订,并希望在工作日分组的PDF文件中打印预订。除了预订所属的工作日外,一切正常。

为了说明我的问题,我制作了生成的PDF文件的屏幕截图:

WeeklyBPlan

如图所示,前三个预订属于25.Dezember.2012。如果我在我发布的代码中添加了xsl:for-each,那么每个预订都会显示工作日。

如果我将xsl:for-each放在表格主体中,所有预订,无论预订属于26.dezember还是27.dezember,都会被分配到25.dezember。我不知道我做错了什么。如何正确打印工作日的预订?

<xsl:template match="/">

    <fo:root>

        <!-- defines the layout master -->
        <fo:layout-master-set>
            <fo:simple-page-master master-name="first"
                                   page-height="29.7cm"
                                   page-width="21cm"
                                   margin-top="1cm"
                                   margin-bottom="2cm"
                                   margin-left="2cm"
                                   margin-right="2cm">
                <fo:region-body margin-top="3cm" margin-bottom="1.5cm"/>

                <fo:region-before region-name="kopf" extent="3cm"/>
                <fo:region-after region-name="fuss" extent="1.5cm"/>
            </fo:simple-page-master>

            <fo:simple-page-master master-name="quer"
                   page-width="29.7cm"
                   page-height="21cm"
                   margin-top="1cm"
                   margin-bottom="2cm"
                   margin-left="2cm"
                   margin-right="2cm">
                <fo:region-body margin-top="1cm" margin-bottom="1.5cm" />

              <fo:region-before region-name="kopf" extent="1cm"/>
              <fo:region-after region-name="fuss" extent="0.5cm"/>

            </fo:simple-page-master>
        </fo:layout-master-set>



        <!-- starts actual layout -->
        <fo:page-sequence master-reference="quer">

            <fo:static-content flow-name="kopf">
                <fo:block  font-weight="bold" text-align="center" font-family="Arial" font-size="18pt">
                    <xsl:text>Test</xsl:text>
                </fo:block>

            </fo:static-content>

            <fo:static-content flow-name="fuss">
                <fo:block border-bottom-width="thin" border-bottom-style="solid"
                 border-bottom-color="black" font-weight="bold" text-align="right" font-family="Arial" font-size="9pt">
                    erstellt am:
                    <xsl:value-of select="lfsExtension:FormatDateTime(.//Erstellt, 'dd.MM.yy HH:mm')"/>
                    <xsl:text> Seite: </xsl:text><fo:page-number/>/<fo:page-number-citation ref-id="lastBlock"/>
                </fo:block>
            </fo:static-content>


            <fo:flow flow-name="xsl-region-body">

                 <!--this defines a title level 1 -->

              <xsl:for-each select=".//WeeklyBPlan" >

                  <fo:block


                            line-height="24pt"
                            space-after.optimum="15pt"
                            padding-top="3pt">
                      <xsl:value-of select=".//WEEKDAY" /> 
                    </fo:block>


                <!-- table start -->
                <fo:table table-layout="fixed" border="solid" border-collapse="collapse" border-width="0.5pt">
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="12mm"/>
                    <fo:table-column column-width="20mm"/>
                                <fo:table-column column-width="50mm"/>
                    <fo:table-column column-width="20mm"/>
                    <fo:table-column column-width="25mm"/>
                                <fo:table-column column-width="10mm"/>
                    <fo:table-column column-width="30mm"/>
                    <fo:table-column column-width="35mm"/>
                    <fo:table-column column-width="35mm"/>
                    <fo:table-header>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Raum</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Zeit</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Abteilung</fo:block>
                            </fo:table-cell>
                                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Thema</fo:block>
                            </fo:table-cell>
                                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Mieter</fo:block>
                            </fo:table-cell>
                                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Tel.-Nr</fo:block>
                            </fo:table-cell>
                                            <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">PAnz</fo:block>
                            </fo:table-cell>
                           <fo:table-cell>
                            <fo:block background-color="grey"
                      color="white" text-align="center">Bestuhlung</fo:block>
                           </fo:table-cell>
                                           <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Bemerkung</fo:block>
                            </fo:table-cell>
                                           <fo:table-cell>
                                <fo:block background-color="grey"
                      color="white" text-align="center">Ausstattung</fo:block>
                            </fo:table-cell>
                           </fo:table-row>
                      <fo:table-row>
                      </fo:table-row>
                    </fo:table-header>
                    <fo:table-body>

                            <fo:table-row>
                                <fo:table-cell  border-right-width="0.5pt" border-right-style="solid"  border-bottom-width="0.5pt" border-bottom-style="solid" padding-right="6pt" padding-left="6pt" >
                                    <fo:block font-family="Arial" font-size="9pt"  padding="2pt">
                                        <xsl:value-of select=".//Raum" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-right-width="0.5pt" border-right-style="solid" border-bottom-width="0.5pt" border-bottom-style="solid">
                                    <fo:block font-family="Arial" font-size="9pt"  padding="2pt"  text-align="center">
                                        <xsl:value-of select=".//Zeit" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-right-width="0.5pt" border-right-style="solid" border-bottom-width="0.5pt" border-bottom-style="solid">
                                    <fo:block font-family="Arial" font-size="9pt" padding="2pt" text-align="center">
                                        <xsl:value-of select=".//Abteilung" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-right-width="0.5pt" border-right-style="solid"  border-bottom-width="0.5pt" border-bottom-style="solid" padding-left="6pt" padding-right="6pt">

                                       <fo:block font-family="Arial" font-size="9pt"  padding="2pt" wrap-option="no-wrap" >
                                        <xsl:value-of select=".//Thema" />
                                       </fo:block>

                                </fo:table-cell>
                              <fo:table-cell border-right-width="0.5pt" border-right-style="solid" border-bottom-width="0.5pt" border-bottom-style="solid">
                                <fo:block font-family="Arial" font-size="9pt"  padding="2pt" text-align="center">
                                  <xsl:value-of select=".//Mieter" />
                                </fo:block>
                              </fo:table-cell>
                              <fo:table-cell border-right-width="0.5pt" border-right-style="solid" border-bottom-width="0.5pt" border-bottom-style="solid">

                                <fo:block font-family="Arial" font-size="9pt"  padding="2pt" text-align="center">
                                  <xsl:value-of select=".//Mieter_Tel" />
                                </fo:block>

                              </fo:table-cell>
                              <fo:table-cell border-right-width="0.5pt" border-right-style="solid" border-bottom-width="0.5pt" border-bottom-style="solid">
                                <fo:block font-family="Arial" font-size="9pt"  padding="2pt" text-align="center">
                                  <xsl:value-of select=".//Personen" />
                                </fo:block>
                              </fo:table-cell>
                              <fo:table-cell border-right-width="0.5pt" border-right-style="solid" border-bottom-width="0.5pt" border-bottom-style="solid"> 
                                <fo:block  font-family="Arial" font-size="9pt" padding="2pt" text-align="center">
                                  <xsl:value-of select=".//Bestuhlung" />
                                </fo:block>
                              </fo:table-cell>
                              <fo:table-cell padding-left="8pt" border-right-style="solid" border-bottom-width="0.5pt" border-right-width="0.5pt" border-bottom-style="solid" >
                                <fo:block  font-family="Arial" font-size="9pt" padding="2pt">
                                  <xsl:value-of select=".//Bemerkung" />
                                </fo:block>
                              </fo:table-cell>
                              <fo:table-cell padding-left="6pt" padding-right="6pt" border-bottom-width="0.5pt" border-bottom-style="solid">
                                <fo:block  font-family="Arial" font-size="9pt" padding="2pt">
                                  <xsl:value-of select=".//Ausstattung" />
                                </fo:block>
                              </fo:table-cell>
                              </fo:table-row>


                    </fo:table-body>
                  </fo:table>
                  <!-- table end -->


              </xsl:for-each>


              <fo:block id="lastBlock"/>
            </fo:flow>




        </fo:page-sequence>

    </fo:root>

</xsl:template>

1 个答案:

答案 0 :(得分:0)

使用for-each-group按日期分组

<xsl:for-each-group select=".//WeeklyBPlan" group-by="/WEEKDAY">
 <fo:block line-height="24pt" space-after.optimum="15pt"
                        padding-top="3pt">
                  <xsl:value-of select="current-grouping-key()" /> 
                </fo:block>
    //table header here
    <xsl:for-each select="current-group()">
        // populate table row
    </xsl:for-each>
 </xsl:for-each-group>