This section covers solutions of how you can use the page range of an input spooled file in order to only process a sub section of a spooled file specified on the PAGERANGE parameter as a from and to page number.
These scenarios are covered below:
When you map the contents of an input spooled file, then you will normally insert as repeat loop, that iterates across all of the pages in the input spooled file with the //page option as described here.
The input spooled file can however be limited in regards to a specific page range like shown below (where only page 17 to 27 are selected):
Work with Spooled File Attributes Job . . . . . . . . : QPADEV0003 File . . . . . . . . : QPJOBLOG User . . . . . . . : KSE Number . . . . . . : 000001 Number . . . . . . : 875518 Creation date . . : 08/06/23 Job system name . . : PMK250 Creation time . . : 16:13:25 Page range to print: Starting page . . . . . . . . . . . : 17 Ending page . . . . . . . . . . . . : 27
This is setup on the PAGERANGE parameter on the spooled file.
The starting page and ending page can in the designer be found as the spooled file attributes://@startPage and //@endPage, so in the case above the //@startPage attribute contains the value 17 and //@endPage contains the value 27.
So we want the designer to limit a //page repeat loop to only run through the pages in the range 17 to 27. The current page number can be found with the Xpath function: position().
We can do that with this setup:
///page[position() >= //@startPage and position()<=//@endPage]
The expression inside [] limits the page (nodes) to only include the spooled file pages, where the expression inside is true. In the condition the condition is set, so that the expression is only true if the current page (found via the function: position() ) is larger or equal to the start page (of the page range) and less or equal to the end page.
If you want to combine the PAGERANGE parameter of the input spooled file with a split e.g. to generate multiple PDF files or emails from a single input spooled file, then you should follow the procedure below. The procedure first changes the payload containing the spooled file, so that it only contains the subset of pages before the spooled file split is executed.
This is possible with these workflow components:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ng="http://www.interform400.com/"
version="2.0">
<xsl:output indent="yes" method="xml"/>
<xsl:param name="StartPage"/>
<xsl:param name="EndPage"/>
<xsl:template match="/">
<spool>
<xsl:attribute name="copies">
<xsl:value-of select="/spool/@copies"/>
</xsl:attribute>
<xsl:attribute name="cpiChg">
<xsl:value-of select="/spool/@cpiChg"/>
</xsl:attribute>
<xsl:attribute name="created">
<xsl:value-of select="/spool/@created"/>
</xsl:attribute>
<xsl:attribute name="crtDate">
<xsl:value-of select="/spool/@crtDate"/>
</xsl:attribute>
<xsl:attribute name="crtTime">
<xsl:value-of select="/spool/@crtTime"/>
</xsl:attribute>
<xsl:attribute name="devFile">
<xsl:value-of select="/spool/@devFile"/>
</xsl:attribute>
<xsl:attribute name="devLib">
<xsl:value-of select="/spool/@devLib"/>
</xsl:attribute>
<xsl:attribute name="endPage">
<xsl:value-of select="/spool/@endPage"/>
</xsl:attribute>
<xsl:attribute name="formtype">
<xsl:value-of select="/spool/@formtype"/>
</xsl:attribute>
<xsl:attribute name="hldBfWrt">
<xsl:value-of select="/spool/@hldBfWrt"/>
</xsl:attribute>
<xsl:attribute name="jobName">
<xsl:value-of select="/spool/@jobName"/>
</xsl:attribute>
<xsl:attribute name="jobNbr">
<xsl:value-of select="/spool/@jobNbr"/>
</xsl:attribute>
<xsl:attribute name="outq">
<xsl:value-of select="/spool/@outq"/>
</xsl:attribute>
<xsl:attribute name="outqLib">
<xsl:value-of select="/spool/@outqLib"/>
</xsl:attribute>
<xsl:attribute name="pageLength">
<xsl:value-of select="/spool/@pageLength"/>
</xsl:attribute>
<xsl:attribute name="pageWidth">
<xsl:value-of select="/spool/@pageWidth"/>
</xsl:attribute>
<xsl:attribute name="pgm">
<xsl:value-of select="/spool/@pgm"/>
</xsl:attribute>
<xsl:attribute name="pgmLib">
<xsl:value-of select="/spool/@pgmLib"/>
</xsl:attribute>
<xsl:attribute name="savAftWrt">
<xsl:value-of select="/spool/@savAftWrt"/>
</xsl:attribute>
<xsl:attribute name="splf">
<xsl:value-of select="/spool/@splf"/>
</xsl:attribute>
<xsl:attribute name="splfNbr">
<xsl:value-of select="/spool/@splfNbr"/>
</xsl:attribute>
<xsl:attribute name="splfVersion">
<xsl:value-of select="/spool/@splfVersion"/>
</xsl:attribute>
<xsl:attribute name="srcDrwr">
<xsl:value-of select="/spool/@srcDrwr"/>
</xsl:attribute>
<xsl:attribute name="startPage">
<xsl:value-of select="/spool/@startPage"/>
</xsl:attribute>
<xsl:attribute name="system">
<xsl:value-of select="/spool/@system"/>
</xsl:attribute>
<xsl:attribute name="totalPages">
<xsl:value-of select="/spool/@totalPages"/>
</xsl:attribute>
<xsl:attribute name="user">
<xsl:value-of select="/spool/@user"/>
</xsl:attribute>
<xsl:attribute name="userData">
<xsl:value-of select="/spool/@userData"/>
</xsl:attribute>
<!-- Copy pages in selected range -->
<xsl:for-each select="//page[position() >= $StartPage and position() <= $EndPage]">
<xsl:copy-of select="."/>
</xsl:for-each>
</spool>
</xsl:template>
</xsl:stylesheet>