Je génère des documents PDF avec XSL-FO et j'ai des tables qui peuvent s'étendre sur plusieurs pages. Dans ce cas, ce que je veux faire est de répéter l'en-tête de la table au début de chaque nouvelle page, avec une étiquette "(suite)" sur toutes les pages sauf la première.En-tête de table continue XSL-FO
Mon code XSL:
<xsl:template name="Tooling">
<fo:table xsl:use-attribute-sets="tableDefaultLayout">
<fo:table-column column-width="37mm" />
<fo:table-column column-width="37mm" />
<fo:table-column column-width="74mm" />
<fo:table-column column-width="37mm" />
<fo:table-header xsl:use-attribute-sets="categoryDefaultFont">
<fo:table-row height="7.7mm" border="0pt solid black" display-align="before" text-align="start">
<fo:table-cell number-columns-spanned="4" font-size="12pt">
<fo:block margin-top="3mm">
<fo:retrieve-table-marker retrieve-class-name="continued"
retrieve-position-within-table="first-starting"
retrieve-boundary-within-table="table-fragment"/>
 
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row xsl:use-attribute-sets="defaultBodyRow" height="4.7mm" border="0pt solid black">
<fo:table-cell>
<fo:block>
<xsl:text>Item No.</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>Part No.</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>Description</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>Qty Reqd</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body xsl:use-attribute-sets="valueDefaultFont" font-size="8pt">
<xsl:for-each select="1 to 50">
<fo:table-row xsl:use-attribute-sets="defaultBodyRow" border="0pt solid black">
<fo:table-cell>
<fo:block>
<xsl:choose>
<xsl:when test="position()=1">
<fo:marker marker-class-name="continued">
<xsl:text>TOOLING:-</xsl:text>
</fo:marker>
</xsl:when>
<xsl:otherwise>
<fo:marker marker-class-name="continued">
<xsl:text>TOOLING: (continued)</xsl:text>
</fo:marker>
</xsl:otherwise>
</xsl:choose>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:text>[email protected]</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:template>
Et la FO générée:
<fo:table border-bottom="0.5pt solid black" border-collapse="collapse" border-left="1pt solid black" border-right="1pt solid black" border-top="0.5pt solid black" margin="0mm" padding="0mm" table-layout="fixed" width="100%">
<fo:table-column column-width="37mm"/>
<fo:table-column column-width="37mm"/>
<fo:table-column column-width="74mm"/>
<fo:table-column column-width="37mm"/>
<fo:table-header font-family="sans-serif" font-size="10pt" font-weight="bold">
<fo:table-row border="0pt solid black" display-align="before" height="7.7mm" text-align="start">
<fo:table-cell font-size="12pt" number-columns-spanned="4">
<fo:block margin-top="3mm">
<fo:retrieve-table-marker retrieve-boundary-within-table="table-fragment" retrieve-class-name="continued" retrieve-position-within-table="first-starting"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="0pt solid black" display-align="center" height="4.7mm" keep-together.within-page="always" text-align="center">
<fo:table-cell>
<fo:block>Item No.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Part No.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Description</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>Qty Reqd</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body font-family="monospace" font-size="8pt" font-weight="normal">
<fo:table-row border="0pt solid black" display-align="center" height="7.74mm" keep-together.within-page="always" text-align="center">
<fo:table-cell>
<fo:block>
<fo:marker marker-class-name="continued">TOOLING:-</fo:marker>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border="0pt solid black" display-align="center" height="7.74mm" keep-together.within-page="always" text-align="center">
<fo:table-cell>
<fo:block>
<fo:marker marker-class-name="continued">TOOLING: (continued)</fo:marker>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>[email protected]</fo:block>
</fo:table-cell>
</fo:table-row>
continue ensuite pour 50 lignes: comme vous pouvez voir le premier a un marqueur "OUTILLAGES: -" et tout les autres ont un marqueur "OUTILLAGE: (suite)", ce que je veux. Mon problème est que je n'arrive pas à faire fonctionner correctement l'objet fo: retrieve-table-marker: j'ai essayé plusieurs combinaisons avec les attributs "retrieve-position" et "retrieve-boundary" mais chaque fois la première ligne de mon en-tête est toujours vide, sur la première ou sur les autres pages.
Si quelqu'un pouvait m'expliquer ce que je fais de mal avec ces objets "fo: retrieve-table-marker" et "fo: marker", ce serait une aide précieuse, j'ai eu du mal avec ce problème pour quelques jours maintenant.
J'ai eu un problème similaire il y a un moment (en essayant de récupérer un marqueur avant la première occurrence de fo: marker), et a travaillé autour d'elle en plaçant une instance supplémentaire de fo: marker avant mon premier marqueur de récupération. Pas la façon dont cela devrait fonctionner, cependant. – Hobbes
Vous avez défini 'table-omit-header-at-break =" true "'. Comme les marqueurs ne peuvent être utilisés que dans l'en-tête du tableau, si vous ne demandez pas d'afficher l'en-tête du tableau, le message ** Suite ** n'apparaîtra pas. Sinon, le reste de votre code est correct. – potame
Désolé, le "table-omit-header-at-break" est une erreur de copier/coller, j'ai essayé d'ajouter cet attribut pour voir ce qu'il a fait, mais il n'a pas de relation avec mon problème. @Hobbes merci pour le pourboire, je vais essayer ceci – eipiplusun