如何在XSL FO表中保持内容

时间:2014-09-17 14:30:28

标签: xslt xsl-fo

我有XSL-FO,包括region-before,region-after和region-body,它有一个包含6列的表。第二列有3行数据(名称,地址,城市/州/邮编)。我们将其渲染为PDF。

如果我只是应用我的数据,我会在页面末尾找到一行,其中第二列在当前页面上有1行文本,并且下一页最后有2行。

如果我申请keep-together =“always”(或keep-together.within-column =“always”),我的表格将从第2页开始。

如何才能让我的数据正确分页?如果我没有提供足够的信息,请发表评论,我会尽力提供。

编辑:XSL-FO附件;添加了样式表和XML;添加了XSLT的其余部分

XML数据:

    <?xml version="1.0" encoding="utf-8"?>
<AS400_ELVPLOC00Collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <COL_FILL_MODE>0</COL_FILL_MODE>
  <IS_CHANGED>false</IS_CHANGED>
  <IS_CHILDREN>true</IS_CHILDREN>
  <SLMR_ERROR_LIST />
  <ObjList>
    <AS400_ELVPLOC00>
      <ID>0</ID>
  <DOC_LINK_ID>0</DOC_LINK_ID>
  <EMAIL_LINK_ID>0</EMAIL_LINK_ID>
  <IS_CHANGED>false</IS_CHANGED>
  <IS_CHILDREN>true</IS_CHILDREN>
  <OBJ_TYPE>AS400_ELVPLOC00</OBJ_TYPE>
  <CRTD_DT>0001-01-01T00:00:00</CRTD_DT>
  <MODFD_DT>0001-01-01T00:00:00</MODFD_DT>
  <SLMR_ERROR_LIST />
  <ELBLDGCD>11966</ELBLDGCD>
  <ELBLDGCD_DISPLAY>11966</ELBLDGCD_DISPLAY>
  <ELBLDGNM>TEST COMPANY</ELBLDGNM>
  <ELLSTNUM>123</ELLSTNUM>
  <ELLDIR></ELLDIR>
  <ELLRDNUM>0</ELLRDNUM>
  <ELLSTNM1>Nowhere</ELLSTNM1>
  <ELLTYP1>St</ELLTYP1>
  <ELLCITY>HARRISBURG</ELLCITY>
  <ELLSTATE>PA</ELLSTATE>
  <ELLZIPCD>17111</ELLZIPCD>
  <ELLZIPCD_DISPLAY>18970</ELLZIPCD_DISPLAY>
  <ELLZIPSX>0</ELLZIPSX>
  <ELLZIPSX_DISPLAY />
  <LOC_STREET_DISPLAY>123 Nowhere St</LOC_STREET_DISPLAY>
  <LOC_STREET_DISPLAY2> </LOC_STREET_DISPLAY2>
  <LOC_DISPLAY_NONUM>123 Nowhere St&lt;br /&gt;HARRISBURG PA 17111</LOC_DISPLAY_NONUM>
  <ELLCNTY>42017</ELLCNTY>
  <ELLCNTY_NAME>Bucks</ELLCNTY_NAME>
  <ELLCURRYY>0</ELLCURRYY>
  <ELLCURRMM>0</ELLCURRMM>
  <ELLCURRDD>0</ELLCURRDD>
  <ELLCurrStatus_DT>0001-01-01T00:00:00</ELLCurrStatus_DT>
  <FEE_CO_ID>0</FEE_CO_ID>
  <INSPTR_ID>0</INSPTR_ID>
  <ELLUPDTYY>0</ELLUPDTYY>
  <ELLUPDTMM>0</ELLUPDTMM>
  <ELLUPDTDD>0</ELLUPDTDD>
  <ELLLastUpdate_DT>0001-01-01T00:00:00</ELLLastUpdate_DT>
  <ELLPASTYY>0</ELLPASTYY>
  <ELLPASTMM>0</ELLPASTMM>
  <ELLPASTDD>0</ELLPASTDD>
  <ELEPastStat_DT>0001-01-01T00:00:00</ELEPastStat_DT>
  <AS400_ELVPEQP_COL>
    <COL_FILL_MODE>0</COL_FILL_MODE>
    <IS_CHANGED>false</IS_CHANGED>
    <IS_CHILDREN>true</IS_CHILDREN>
    <SLMR_ERROR_LIST />
    <ObjList>
      <AS400_ELVPEQP00>
        <ID>114224</ID>
        <DOC_LINK_ID>0</DOC_LINK_ID>
        <EMAIL_LINK_ID>0</EMAIL_LINK_ID>
        <IS_CHANGED>false</IS_CHANGED>
        <IS_CHILDREN>true</IS_CHILDREN>
        <OBJ_TYPE>AS400_ELVPEQP00</OBJ_TYPE>
        <CRTD_DT>0001-01-01T00:00:00</CRTD_DT>
        <MODFD_DT>0001-01-01T00:00:00</MODFD_DT>
        <SLMR_ERROR_LIST />
        <ELBLDGCD>11966</ELBLDGCD>
        <ELEEQNO>1</ELEEQNO>
        <ELEEQNO_DISPLAY>001</ELEEQNO_DISPLAY>
        <ELEDTINY>1947</ELEDTINY>
        <ELEDTINM>10</ELEDTINM>
        <ELEDTIND>2</ELEDTIND>
        <ELEInitInsp_DT>1947-10-02T00:00:00</ELEInitInsp_DT>
        <ELEIRSLT>P</ELEIRSLT>
        <ELEICDTY>0</ELEICDTY>
        <ELEICDTM>0</ELEICDTM>
        <ELEICDTD>0</ELEICDTD>
        <ELEClear_DT>1900-01-01T00:00:00</ELEClear_DT>
        <ELPERMTNO>194703851</ELPERMTNO>
        <ELEPERMID>N</ELEPERMID>
        <ELEDTISY>0</ELEDTISY>
        <ELEDTISM>0</ELEDTISM>
        <ELEDTISD>0</ELEDTISD>
        <ELEPermitIssued_DT>1900-01-01T00:00:00</ELEPermitIssued_DT>
        <ELELSEAL />
        <ELEYCEXP>0</ELEYCEXP>
        <ELEMCEXP>0</ELEMCEXP>
        <ELECEXP_DT>0001-01-01T00:00:00</ELECEXP_DT>
        <ELEYCISS>0</ELEYCISS>
        <ELEMCISS>0</ELEMCISS>
        <ELOFLNUM>11966</ELOFLNUM>
        <ELERPNUM>11966</ELERPNUM>
        <ELETYPELV>F</ELETYPELV>
        <ELEINSPD>2</ELEINSPD>
        <ELEDTWINY>0</ELEDTWINY>
        <ELEDTWINM>0</ELEDTWINM>
        <ELEDTWIND>0</ELEDTWIND>
        <ELEMajRepair_DT>1900-01-01T00:00:00</ELEMajRepair_DT>
        <ELEWCDTY>0</ELEWCDTY>
        <ELEWCDTM>0</ELEWCDTM>
        <ELEWCDTD>0</ELEWCDTD>
        <ELEMajRepairClear_DT>1900-01-01T00:00:00</ELEMajRepairClear_DT>
        <ELEDTLINY>2008</ELEDTLINY>
        <ELEDTLINM>2</ELEDTLINM>
        <ELEDTLIND>21</ELEDTLIND>
        <ELELastInsp_DT>2008-02-21T00:00:00</ELELastInsp_DT>
        <ELELAST_INSP_ID>1369887</ELELAST_INSP_ID>
        <ELEUPDTYY>0</ELEUPDTYY>
        <ELEUPDTMM>0</ELEUPDTMM>
        <ELEUPDTDD>0</ELEUPDTDD>
        <ELELastUpdate_DT>0001-01-01T00:00:00</ELELastUpdate_DT>
        <ELELocId>0</ELELocId>
        <ELEBldgOpwnId>0</ELEBldgOpwnId>
        <ELERespOwnId>0</ELERespOwnId>
        <ELEPassID>0</ELEPassID>
        <ELESkiID>0</ELESkiID>
        <ELEWclID>0</ELEWclID>
        <ELEECOCD_ID>0</ELEECOCD_ID>
        <ELEEORIG_ID>0</ELEEORIG_ID>
        <FIRST_INSP_ID>0</FIRST_INSP_ID>
        <LAST_MAJ_REP_INSP_ID>0</LAST_MAJ_REP_INSP_ID>
      </AS400_ELVPEQP00>
      <AS400_ELVPEQP00>
        <ID>114225</ID>
        <DOC_LINK_ID>0</DOC_LINK_ID>
        <EMAIL_LINK_ID>0</EMAIL_LINK_ID>
        <IS_CHANGED>false</IS_CHANGED>
        <IS_CHILDREN>true</IS_CHILDREN>
        <OBJ_TYPE>AS400_ELVPEQP00</OBJ_TYPE>
        <CRTD_DT>0001-01-01T00:00:00</CRTD_DT>
        <MODFD_DT>0001-01-01T00:00:00</MODFD_DT>
        <SLMR_ERROR_LIST />
        <ELBLDGCD>11966</ELBLDGCD>
        <ELEEQNO>2</ELEEQNO>
        <ELEEQNO_DISPLAY>002</ELEEQNO_DISPLAY>
        <ELEDTINY>1947</ELEDTINY>
        <ELEDTINM>10</ELEDTINM>
        <ELEDTIND>2</ELEDTIND>
        <ELEInitInsp_DT>1947-10-02T00:00:00</ELEInitInsp_DT>
        <ELEIRSLT>P</ELEIRSLT>
        <ELEICDTY>0</ELEICDTY>
        <ELEICDTM>0</ELEICDTM>
        <ELEICDTD>0</ELEICDTD>
        <ELEClear_DT>1900-01-01T00:00:00</ELEClear_DT>
        <ELPERMTNO>194703851</ELPERMTNO>
        <ELEPERMID>N</ELEPERMID>
        <ELEDTISY>0</ELEDTISY>
        <ELEDTISM>0</ELEDTISM>
        <ELEDTISD>0</ELEDTISD>
        <ELEPermitIssued_DT>1900-01-01T00:00:00</ELEPermitIssued_DT>
        <ELELSEAL />
        <ELEYCEXP>0</ELEYCEXP>
        <ELEMCEXP>0</ELEMCEXP>
        <ELECEXP_DT>0001-01-01T00:00:00</ELECEXP_DT>
        <ELEYCISS>0</ELEYCISS>
        <ELEMCISS>0</ELEMCISS>
        <ELOFLNUM>11966</ELOFLNUM>
        <ELERPNUM>11966</ELERPNUM>
        <ELETYPELV>F</ELETYPELV>
        <ELEINSPD>2</ELEINSPD>
        <ELEDTWINY>0</ELEDTWINY>
        <ELEDTWINM>0</ELEDTWINM>
        <ELEDTWIND>0</ELEDTWIND>
        <ELEMajRepair_DT>1900-01-01T00:00:00</ELEMajRepair_DT>
        <ELEWCDTY>0</ELEWCDTY>
        <ELEWCDTM>0</ELEWCDTM>
        <ELEWCDTD>0</ELEWCDTD>
        <ELEMajRepairClear_DT>1900-01-01T00:00:00</ELEMajRepairClear_DT>
        <ELEDTLINY>2008</ELEDTLINY>
        <ELEDTLINM>2</ELEDTLINM>
        <ELEDTLIND>21</ELEDTLIND>
        <ELELastInsp_DT>2008-02-21T00:00:00</ELELastInsp_DT>
        <ELELAST_INSP_ID>1369887</ELELAST_INSP_ID>
        <ELEUPDTYY>0</ELEUPDTYY>
        <ELEUPDTMM>0</ELEUPDTMM>
        <ELEUPDTDD>0</ELEUPDTDD>
        <ELELastUpdate_DT>0001-01-01T00:00:00</ELELastUpdate_DT>
        <ELELocId>0</ELELocId>
        <ELEBldgOpwnId>0</ELEBldgOpwnId>
        <ELERespOwnId>0</ELERespOwnId>
        <ELEPassID>0</ELEPassID>
        <ELESkiID>0</ELESkiID>
        <ELEWclID>0</ELEWclID>
        <ELEECOCD_ID>0</ELEECOCD_ID>
        <ELEEORIG_ID>0</ELEEORIG_ID>
        <FIRST_INSP_ID>0</FIRST_INSP_ID>
        <LAST_MAJ_REP_INSP_ID>0</LAST_MAJ_REP_INSP_ID>
      </AS400_ELVPEQP00>
    </ObjList>
    <Sort_Expression />
    <Sort_Expression_List />
    <Sort_Direction>Asc</Sort_Direction>
    <SEARCH_ELBLDGCD>0</SEARCH_ELBLDGCD>
    <SEARCH_ELEEQNO>0</SEARCH_ELEEQNO>
    <SEARCH_ELEFLNUM>0</SEARCH_ELEFLNUM>
    <SEARCH_ELERPNUM>0</SEARCH_ELERPNUM>
    <SEARCH_ELPERMTNO>0</SEARCH_ELPERMTNO>
    <SEARCH_ELPERMTNO_LIST />
    <SEARCH_INSPTRID>0</SEARCH_INSPTRID>
    <SEARCH_INSPNDT_START>12:00:00 AM</SEARCH_INSPNDT_START>
    <SEARCH_INSPNDT_END>12:00:00 AM</SEARCH_INSPNDT_END>
  </AS400_ELVPEQP_COL>
  <LastEqpNum>0</LastEqpNum>
  <NumOfEqp>0</NumOfEqp>
  <PRVNC>0</PRVNC>
  <CTRY>0</CTRY>
  <DIVN>ELV</DIVN>
  <FILE_NUMBER>0</FILE_NUMBER>
  <OWNER_ID>0</OWNER_ID>
  <Original_ObjType>AS400_ELVPLOC00</Original_ObjType>
  <ASGD_WRKLD_INSPTR_ID>0</ASGD_WRKLD_INSPTR_ID>
</AS400_ELVPLOC00>
<AS400_ELVPLOC00>
  <ID>0</ID>
  <DOC_LINK_ID>0</DOC_LINK_ID>
  <EMAIL_LINK_ID>0</EMAIL_LINK_ID>
  <IS_CHANGED>false</IS_CHANGED>
  <IS_CHILDREN>true</IS_CHILDREN>
  <OBJ_TYPE>AS400_ELVPLOC00</OBJ_TYPE>
  <CRTD_DT>0001-01-01T00:00:00</CRTD_DT>
  <MODFD_DT>0001-01-01T00:00:00</MODFD_DT>
  <SLMR_ERROR_LIST />
  <ELBLDGCD>26778</ELBLDGCD>
  <ELBLDGCD_DISPLAY>26778</ELBLDGCD_DISPLAY>
  <ELBLDGNM>ANOTHER COMPANY</ELBLDGNM>
  <ELLSTNUM />
  <ELLDIR>E</ELLDIR>
  <ELLRDNUM>0</ELLRDNUM>
  <ELLSTNM1>POST</ELLSTNM1>
  <ELLTYP1>RD</ELLTYP1>
  <ELLCITY>HARRISBURG</ELLCITY>
  <ELLSTATE>PA</ELLSTATE>
  <ELLZIPCD>17111</ELLZIPCD>
  <ELLZIPCD_DISPLAY>19067</ELLZIPCD_DISPLAY>
  <ELLZIPSX>0</ELLZIPSX>
  <ELLZIPSX_DISPLAY />
  <LOC_STREET_DISPLAY>E POST RD</LOC_STREET_DISPLAY>
  <LOC_STREET_DISPLAY2> </LOC_STREET_DISPLAY2>
  <LOC_DISPLAY_NONUM>ANOTHER COMPANY&lt;br /&gt;E POST RD&lt;br /&gt;HARRISBURG PA 17111</LOC_DISPLAY_NONUM>
  <ELLCNTY>42017</ELLCNTY>
  <ELLCNTY_NAME>Bucks</ELLCNTY_NAME>
  <ELLCURRYY>0</ELLCURRYY>
  <ELLCURRMM>0</ELLCURRMM>
  <ELLCURRDD>0</ELLCURRDD>
  <ELLCurrStatus_DT>0001-01-01T00:00:00</ELLCurrStatus_DT>
  <FEE_CO_ID>0</FEE_CO_ID>
  <INSPTR_ID>0</INSPTR_ID>
  <ELLUPDTYY>0</ELLUPDTYY>
  <ELLUPDTMM>0</ELLUPDTMM>
  <ELLUPDTDD>0</ELLUPDTDD>
  <ELLLastUpdate_DT>0001-01-01T00:00:00</ELLLastUpdate_DT>
  <ELLPASTYY>0</ELLPASTYY>
  <ELLPASTMM>0</ELLPASTMM>
  <ELLPASTDD>0</ELLPASTDD>
  <ELEPastStat_DT>0001-01-01T00:00:00</ELEPastStat_DT>
  <AS400_ELVPEQP_COL>
    <COL_FILL_MODE>0</COL_FILL_MODE>
    <IS_CHANGED>false</IS_CHANGED>
    <IS_CHILDREN>true</IS_CHILDREN>
    <SLMR_ERROR_LIST />
    <ObjList>
      <AS400_ELVPEQP00>
        <ID>77581</ID>
        <DOC_LINK_ID>0</DOC_LINK_ID>
        <EMAIL_LINK_ID>0</EMAIL_LINK_ID>
        <IS_CHANGED>false</IS_CHANGED>
        <IS_CHILDREN>true</IS_CHILDREN>
        <OBJ_TYPE>AS400_ELVPEQP00</OBJ_TYPE>
        <CRTD_DT>0001-01-01T00:00:00</CRTD_DT>
        <MODFD_DT>0001-01-01T00:00:00</MODFD_DT>
        <SLMR_ERROR_LIST />
        <ELBLDGCD>26778</ELBLDGCD>
        <ELEEQNO>7</ELEEQNO>
        <ELEEQNO_DISPLAY>007</ELEEQNO_DISPLAY>
        <ELEDTINY>0</ELEDTINY>
        <ELEDTINM>0</ELEDTINM>
        <ELEDTIND>0</ELEDTIND>
        <ELEInitInsp_DT>1900-01-01T00:00:00</ELEInitInsp_DT>
        <ELEIRSLT />
        <ELEICDTY>0</ELEICDTY>
        <ELEICDTM>0</ELEICDTM>
        <ELEICDTD>0</ELEICDTD>
        <ELEClear_DT>1900-01-01T00:00:00</ELEClear_DT>
        <ELPERMTNO>0</ELPERMTNO>
        <ELEPERMID>M0</ELEPERMID>
        <ELEDTISY>0</ELEDTISY>
        <ELEDTISM>0</ELEDTISM>
        <ELEDTISD>0</ELEDTISD>
        <ELEPermitIssued_DT>1900-01-01T00:00:00</ELEPermitIssued_DT>
        <ELELSEAL />
        <ELEYCEXP>0</ELEYCEXP>
        <ELEMCEXP>0</ELEMCEXP>
        <ELECEXP_DT>0001-01-01T00:00:00</ELECEXP_DT>
            <ELEYCISS>0</ELEYCISS>
            <ELEMCISS>0</ELEMCISS>
            <ELOFLNUM>26778</ELOFLNUM>
            <ELERPNUM>26778</ELERPNUM>
            <ELETYPELV>F</ELETYPELV>
            <ELEINSPD>2</ELEINSPD>
            <ELEDTWINY>0</ELEDTWINY>
            <ELEDTWINM>0</ELEDTWINM>
            <ELEDTWIND>0</ELEDTWIND>
            <ELEMajRepair_DT>1900-01-01T00:00:00</ELEMajRepair_DT>
            <ELEWCDTY>0</ELEWCDTY>
            <ELEWCDTM>0</ELEWCDTM>
            <ELEWCDTD>0</ELEWCDTD>
            <ELEMajRepairClear_DT>1900-01-01T00:00:00</ELEMajRepairClear_DT>
            <ELEDTLINY>2010</ELEDTLINY>
            <ELEDTLINM>6</ELEDTLINM>
            <ELEDTLIND>3</ELEDTLIND>
            <ELELastInsp_DT>2010-06-03T00:00:00</ELELastInsp_DT>
            <ELELAST_INSP_ID>1547374</ELELAST_INSP_ID>
            <ELEUPDTYY>0</ELEUPDTYY>
            <ELEUPDTMM>0</ELEUPDTMM>
            <ELEUPDTDD>0</ELEUPDTDD>
            <ELELastUpdate_DT>0001-01-01T00:00:00</ELELastUpdate_DT>
            <ELELocId>0</ELELocId>
            <ELEBldgOpwnId>0</ELEBldgOpwnId>
            <ELERespOwnId>0</ELERespOwnId>
            <ELEPassID>0</ELEPassID>
            <ELESkiID>0</ELESkiID>
            <ELEWclID>0</ELEWclID>
            <ELEECOCD_ID>0</ELEECOCD_ID>
            <ELEEORIG_ID>0</ELEEORIG_ID>
            <FIRST_INSP_ID>0</FIRST_INSP_ID>
            <LAST_MAJ_REP_INSP_ID>0</LAST_MAJ_REP_INSP_ID>
          </AS400_ELVPEQP00>
        </ObjList>
        <Sort_Expression />
        <Sort_Expression_List />
        <Sort_Direction>Asc</Sort_Direction>
        <SEARCH_ELBLDGCD>0</SEARCH_ELBLDGCD>
        <SEARCH_ELEEQNO>0</SEARCH_ELEEQNO>
        <SEARCH_ELEFLNUM>0</SEARCH_ELEFLNUM>
        <SEARCH_ELERPNUM>0</SEARCH_ELERPNUM>
        <SEARCH_ELPERMTNO>0</SEARCH_ELPERMTNO>
        <SEARCH_ELPERMTNO_LIST />
        <SEARCH_INSPTRID>0</SEARCH_INSPTRID>
        <SEARCH_INSPNDT_START>12:00:00 AM</SEARCH_INSPNDT_START>
        <SEARCH_INSPNDT_END>12:00:00 AM</SEARCH_INSPNDT_END>
      </AS400_ELVPEQP_COL>
      <LastEqpNum>0</LastEqpNum>
      <NumOfEqp>0</NumOfEqp>
      <PRVNC>0</PRVNC>
      <CTRY>0</CTRY>
      <DIVN>ELV</DIVN>
      <FILE_NUMBER>0</FILE_NUMBER>
      <OWNER_ID>0</OWNER_ID>
      <Original_ObjType>AS400_ELVPLOC00</Original_ObjType>
      <ASGD_WRKLD_INSPTR_ID>0</ASGD_WRKLD_INSPTR_ID>
    </AS400_ELVPLOC00>
  </ObjList>
  <Sort_Expression />
  <Sort_Expression_List />
  <Sort_Direction>Asc</Sort_Direction>
  <SEARCH_ELBLDGCD>0</SEARCH_ELBLDGCD>
  <SEARCH_ELBLDGNM />
  <SEARCH_ELLCITY />
  <SEARCH_ELOFLNUM>0</SEARCH_ELOFLNUM>
  <SEARCH_ELLSTNAME />
  <SEARCH_Counties>42017,42075</SEARCH_Counties>
  <SEARCH_FromDate>2011-01-01T00:00:00</SEARCH_FromDate>
  <SEARCH_ToDate>2014-06-30T00:00:00</SEARCH_ToDate>
</AS400_ELVPLOC00Collection>

Print_Stylesheet.txt(属性集)

  <xsl:attribute-set name="table">
   <xsl:attribute name="font-family">Arial</xsl:attribute>
    <xsl:attribute name="font-size">10pt</xsl:attribute>
    <xsl:attribute name="table-layout">fixed</xsl:attribute> 
    <xsl:attribute name="space-before">10pt</xsl:attribute>
    <xsl:attribute name="space-after">10pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.data.th" >
    <xsl:attribute name="border-style">solid</xsl:attribute>
    <xsl:attribute name="border-color">black</xsl:attribute>
    <xsl:attribute name="border-width">1pt</xsl:attribute>
    <xsl:attribute name="padding-start">0.3em</xsl:attribute>
    <xsl:attribute name="padding-end">0.2em</xsl:attribute>
    <xsl:attribute name="padding-before">2pt</xsl:attribute>
    <xsl:attribute name="padding-after">2pt</xsl:attribute>
    <xsl:attribute name="text-align">center</xsl:attribute>
    <xsl:attribute name="font-size">9pt</xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.data.td_title" >
    <xsl:attribute name="border-style">solid</xsl:attribute>
    <xsl:attribute name="border-color">black</xsl:attribute>
    <xsl:attribute name="border-width">1pt</xsl:attribute>
    <xsl:attribute name="padding-start">0.3em</xsl:attribute>
    <xsl:attribute name="padding-end">0.2em</xsl:attribute>
    <xsl:attribute name="padding-before">2pt</xsl:attribute>
    <xsl:attribute name="padding-after">2pt</xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.data.td_data" >
    <xsl:attribute name="border-style">solid</xsl:attribute>
    <xsl:attribute name="border-color">black</xsl:attribute>
    <xsl:attribute name="border-width">1pt</xsl:attribute>
    <xsl:attribute name="font-size">9pt</xsl:attribute>
    <xsl:attribute name="padding-start">0.5em</xsl:attribute>
    <xsl:attribute name="padding-end">0.3em</xsl:attribute>
    <xsl:attribute name="padding-before">2pt</xsl:attribute>
    <xsl:attribute name="padding-after">2pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table_PLAN_APRVL">
    <xsl:attribute name="font-family">Arial</xsl:attribute>
    <xsl:attribute name="font-size">9pt</xsl:attribute>
    <xsl:attribute name="line-height">14pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.data.td_titleCell">
    <xsl:attribute name="line-height">10pt</xsl:attribute>
    <xsl:attribute name="font-size">9pt</xsl:attribute>
    <xsl:attribute name="padding-start">0.3em</xsl:attribute>
    <xsl:attribute name="padding-end">0.2em</xsl:attribute>
    <xsl:attribute name="padding-before">1pt</xsl:attribute>
    <xsl:attribute name="padding-after">1pt</xsl:attribute>
    <xsl:attribute name="border-left-style">solid</xsl:attribute>
    <xsl:attribute name="border-left-width">thin</xsl:attribute>
    <xsl:attribute name="border-right-style">solid</xsl:attribute>
    <xsl:attribute name="border-right-width">thin</xsl:attribute>
    <xsl:attribute name="border-top-style">solid</xsl:attribute>
    <xsl:attribute name="border-top-width">thin</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.data.td_innerTitleCell">
    <xsl:attribute name="vertical-align">sub</xsl:attribute>
    <xsl:attribute name="text-align">right</xsl:attribute>
    <xsl:attribute name="font-size">9pt</xsl:attribute>
    <xsl:attribute name="padding-end">0.1em</xsl:attribute>
    <xsl:attribute name="padding-before">1pt</xsl:attribute>
    <xsl:attribute name="padding-after">1pt</xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.data.td_innerCell">
    <xsl:attribute name="vertical-align">sub</xsl:attribute>
    <xsl:attribute name="font-size">9pt</xsl:attribute>
    <xsl:attribute name="padding-before">1pt</xsl:attribute>
    <xsl:attribute name="padding-after">1pt</xsl:attribute>
  </xsl:attribute-set>

   <xsl:attribute-set name="OCR.Data">
    <xsl:attribute name="font-family">OCR A Extended</xsl:attribute>
    <xsl:attribute name="font-size">13pt</xsl:attribute>
    <xsl:attribute name="font-weight">normal</xsl:attribute>
    <xsl:attribute name="font-color">black</xsl:attribute>
  </xsl:attribute-set>

来自XSLT的部分:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>
  <!--Style Sheet-->
  <!--Helper Tools-->
  <xsl:variable name="ind" select="0" />
  <xsl:attribute-set name="table.cell">
    <xsl:attribute name="border-style">solid</xsl:attribute>
    <xsl:attribute name="border-color">black</xsl:attribute>
    <xsl:attribute name="border-width">normal</xsl:attribute>
    <xsl:attribute name="font-size">7pt</xsl:attribute>
    <xsl:attribute name="font-family">Times New Roman</xsl:attribute>
    <xsl:attribute name="text-align">center</xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
    <xsl:attribute name="padding-before">2pt</xsl:attribute>
    <xsl:attribute name="padding-after">2pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:key name="county" match="ObjList/AS400_ELVPLOC00" use="ELLCNTY_NAME" />

  <xsl:template match="AS400_ELVPLOC00Collection">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simple"
                  page-height="11in"
                  page-width="8.5in"
                  margin-top="0.125in"
                  margin-bottom="0.125in"
                  margin-left="0.325in"
                  margin-right="0.325in">

          <fo:region-body margin-top="1.125in"
                      margin-bottom="0.75in"
                      margin-left="0in"
                      margin-right="1in"
            />
          <fo:region-before region-name="xsl-region-before" extent="1in" />
          <fo:region-after region-name="xsl-region-after" extent="0.0in" />
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simple">
        <!-- Page Header-->
        <fo:static-content flow-name="xsl-region-before">
        </fo:static-content>

        <!--Footer-->
        <fo:static-content flow-name="xsl-region-after" >
        </fo:static-content>

        <fo:flow flow-name="xsl-region-body">
          <xsl:for-each select="ObjList/AS400_ELVPLOC00[generate-id(.)=generate-id(key('county',ELLCNTY_NAME)[1])]">

        <fo:flow flow-name="xsl-region-body">
      <xsl:for-each select="ObjList/AS400_ELVPLOC00[generate-id(.)=generate-id(key('county',ELLCNTY_NAME)[1])]">

        <fo:table xsl:use-attribute-sets="table" space-after="0pt" break-after="page">
          <fo:table-column column-number="1" column-width="0.75in" />
          <!-- LOC NO -->
          <fo:table-column column-number="2" column-width="2.85in" />
          <!-- LOCATION -->
          <fo:table-column column-number="3" column-width="1.5in" />
          <!-- EQP/TYPE -->
          <fo:table-column column-number="4" column-width="1.25in" />
          <!-- INSP DATE -->
          <fo:table-column column-number="5" column-width="0.125in" />
          <!-- ? -->
          <fo:table-column column-number="6" column-width="2.0in" />
          <!-- HISTORY -->
          <fo:table-header>
            <!-- Grid Header -->
            <fo:table-row>
              <fo:table-cell number-columns-spanned="2">
                <fo:block>
                  <xsl:text>FOR </xsl:text>
                  <xsl:value-of select="ELLCNTY_NAME" />
                  <xsl:text> COUNTY</xsl:text>
                </fo:block>
              </fo:table-cell>
              <fo:table-cell number-columns-spanned="4">

              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block padding-after="10pt">
                  LOC NO
                </fo:block>
              </fo:table-cell>
              <fo:table-cell text-align="left">
                <fo:block>
                  LOCATION
                </fo:block>
              </fo:table-cell>
              <fo:table-cell text-align="left">
                <fo:block>
                  EQP/TYPE
                </fo:block>
              </fo:table-cell>
              <fo:table-cell text-align="left">
                <fo:block>
                  INSP DATE
                </fo:block>
              </fo:table-cell>
              <fo:table-cell text-align="left">
                <fo:block>

                </fo:block>
              </fo:table-cell>
              <fo:table-cell text-align="left">
                <fo:block>
                  HISTORY
                </fo:block>
              </fo:table-cell>
            </fo:table-row>
          </fo:table-header>

          <!-- Table Grid -->
          <fo:table-body>
            <xsl:for-each select="key('county',ELLCNTY_NAME)">
              <xsl:sort select="ELBLDGCD_DISPLAY" />
              <fo:table-row padding-after="4pt">
                <fo:table-cell>
                  <fo:block>
                    <xsl:value-of select="ELBLDGCD_DISPLAY" />
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell padding-after="5pt">
                  <fo:block>
                    <fo:block>
                      <xsl:value-of select="ELBLDGNM"/>
                    </fo:block>
                    <fo:block>
                      <xsl:value-of select="LOC_STREET_DISPLAY"/>
                    </fo:block>
                    <fo:block>
                      <xsl:value-of select="ELLCITY"/>
                      <xsl:text>, </xsl:text>
                      <xsl:value-of select="ELLSTATE"/>
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="ELLZIPCD"/>
                    </fo:block>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell padding-after="5pt">
                  <fo:block>
                    <xsl:text>...</xsl:text>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell padding-after="5pt">
                  <fo:block>
                    <xsl:text>...</xsl:text>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell padding-after="5pt">
                  <fo:block>
                    <xsl:text>...</xsl:text>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell padding-after="5pt">
                  <fo:block>
                    <xsl:text>...</xsl:text>
                  </fo:block>
                </fo:table-cell>
              </fo:table-row>
            </xsl:for-each>

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

      </xsl:for-each>
    </fo:flow>
  </fo:page-sequence>
    </fo:root>

  </xsl:template>

</xsl:stylesheet>

1 个答案:

答案 0 :(得分:2)

在您发布的XSL中修复了一些问题并检查结果之后,我相信您想要的是重复表中的整行始终保持在页面上。如果是,那么你将在你的XSL中执行此操作:

        <xsl:for-each select="key('county',ELLCNTY_NAME)">
            <xsl:sort select="ELBLDGCD_DISPLAY" />
            <fo:table-row padding-after="4pt" keep-together.within-page="always">

您可以通过在确切的table-cell上设置该值来获得相同的效果:

          <fo:table-cell padding-after="5pt" keep-together.within-page="always">
                    <fo:block>
                        <fo:block>
                            <xsl:value-of select="ELBLDGNM"/>
                        </fo:block>
                        <fo:block>
                            <xsl:value-of select="LOC_STREET_DISPLAY"/>
                        </fo:block>
                        <fo:block>
                            <xsl:value-of select="ELLCITY"/>
                            <xsl:text>, </xsl:text>
                            <xsl:value-of select="ELLSTATE"/>
                            <xsl:text> </xsl:text>
                            <xsl:value-of select="ELLZIPCD"/>
                        </fo:block>
                    </fo:block>
                </fo:table-cell>

甚至包含表格单元格内所有行的包含块。不同之处在于这是否是您想要保持在一起的唯一事物,或者您是否希望将整行保持在一起。

另请注意,这与MSXML无关,应删除该标记。这是一个纯粹的XSL FO保持问题,并且与您使用的XSLT引擎无关。

生成的PDF显示这些单元格在页面之间没有中断:

enter image description here