所以,我是xml和xslt的新手。我正在构建一个带有样式表的xml文件。大多数数据目前都是硬编码到xml中的。这是我的xsl片段(道歉:我遇到一些问题,让整个文件符合Stack的格式标准):
<xsl:template match="/packingList" priority="1">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="basicSPM"
page-width="8.5in" page-height="11.0in"
margin-top="0.5in" margin-bottom="0.5in" margin-left="1.0in" margin-right="1.0in" >
<fo:region-body margin-bottom="0.4in" />
<fo:region-before />
<fo:region-after />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="basicSPM" initial-page-number="1" force-page-count="no-force">
<fo:static-content flow-name="xsl-region-before">
<fo:block />
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block xsl:use-attribute-sets="font-footer">
<fo:table>
<fo:table-column column-number="1" column-width="50%" />
<fo:table-column column-number="2" column-width="50%" />
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="1" text-align="left">
<fo:block>
Print date :
<xsl:value-of select="//currentDateTime" />
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" text-align="right">
<fo:block>
Page
<fo:page-number />
of
<fo:page-number-citation-last ref-id="sectionPageNumberTotal" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="documentType" />
<fo:block id="sectionPageNumberTotal" />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
我想做的事情目前无法做到:
删除生成pdf时生成的额外页面(带页脚)。我发现如果我注释掉这一行 -
<fo:block id="sectionPageNumberTotal" />
- 额外的页面消失了,但是,我的页面编号也是如此。 fo:块导致文档扩展到另一个页面会发生什么?我尝试了各种强制页面计数值,但我不确定它们在这种情况下是否相关。
此外,我想重新开始PDF页面的编号以与每个documentType相对应,因此如果有3页非紧急文档,那么这些页面将被编号为3,2中的3,并且然后,对于N的N,2中的紧急文档1等,将重新开始编号,对于其他文档类型,编号将相同。我已经尝试了各种我在堆栈溢出时发现的解决方案,但我没有任何运气,让我想知道是否有一些根本关于如何将这张表放在一起的东西。如果没有,我可能最终分别渲染不同的文档类型,然后将它们一起添加以实现所需的编号效果。 提前谢谢!
<packingList>
<dateRange th:text="${startDate} + ' to ' + ${endDate}"></dateRange>
<currentDateTime th:text="${currentDateTime}"></currentDateTime>
<documentType>
<name>Non-Emergency</name>
<packageActions>
<packageAction>
<packageActionId>100000</packageActionId>
<fileNames>
<fileName>3701_75_04_PH_FF_A_RU_20160201_0539.pdf</fileName>
<fileName>3701_75_04_PH_FF_A_RS_20160201_0539.pdf</fileName>
<fileName>3701_99_04_PH_FF_A_RU_20160201_0539.pdf</fileName>
</fileNames>
</packageAction>
<packageAction>
<packageActionId>200000</packageActionId>
<fileNames>
<fileName>5101$2-47-23$1_PH_FF_R_RU_20160201_0932.pdf</fileName>
<fileName>5101$2-47-23$1_PH_FF_N_RU_20160201_0932.pdf</fileName>
</fileNames>
</packageAction>
</packageActions>
</documentType>
<documentType>
<name>Emergency</name>
<packageActions>
<packageAction>
<packageActionId>300000</packageActionId>
<fileNames>
<fileName>4707$2-47-23$1_PH_FF_R_RU_20160201_0932.pdf</fileName>
<fileName>4707$2-47-23$1_PH_FF_N_RU_20160201_0932.pdf</fileName>
</fileNames>
</packageAction>
<packageAction>
<packageActionId>400000</packageActionId>
<fileNames>
<fileName>3309-1-12_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>3309-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
</fileNames>
</packageAction>
</packageActions>
</documentType>
<documentType>
<name>Public Hearing Notice</name>
<packageActions>
<packageAction>
<packageActionId>500000</packageActionId>
<fileNames>
<fileName>145$2-47-23$1_PH_FF_R_RU_20160201_0932.pdf</fileName>
<fileName>145$2-47-23$1_PH_FF_N_RU_20160201_0932.pdf</fileName>
</fileNames>
</packageAction>
<packageAction>
<packageActionId>600000</packageActionId>
<fileNames>
<fileName>2222-1-12_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>2222-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>2222-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>2222-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
</fileNames>
</packageAction>
</packageActions>
</documentType>
<documentType>
<name>Correction Letters</name>
<packageActions>
<packageAction>
<packageActionId>700000</packageActionId>
<fileNames>
<fileName>4444$2-47-23$1_PH_FF_R_RU_20160201_0932.pdf</fileName>
<fileName>4444$3-47-23$1_PH_FF_N_RU_20160201_0932.pdf</fileName>
</fileNames>
</packageAction>
<packageAction>
<packageActionId>800000</packageActionId>
<fileNames>
<fileName>8505-1-12_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>8505-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>3309-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>8505-1-12_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>8505-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>3309-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>8505-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>3309-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>8505-1-12_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>8505-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>3309-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>8505-1-12_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>8505-1-44_FYR_C_RU_20160201_1007.pdf</fileName>
<fileName>3309-1-56_FYR_C_RS_20160201_1007.pdf</fileName>
<fileName>3309-1-58_FYR_C_RU_20160201_1007.pdf</fileName>
</fileNames>
</packageAction>
</packageActions>
</documentType>
<documentType>
<name>Guides</name>
<guideDocs>
<guideDoc>
<fileName>RMG_109_20160818.pdf</fileName>
<agency>Environmental Protection Agency</agency>
<dateReceived>7/7/17</dateReceived>
</guideDoc>
<guideDoc>
<fileName>guides.pdf</fileName>
<agency>California Legislative Services</agency>
<dateReceived>8/8/17</dateReceived>
</guideDoc>
</guideDocs>
</documentType>