Pay Statement XSLT Setup

The following are some callouts for our xslt transform file that will take your XML and create a PDF out of it. Besides the items below the xslt is version 1.0 and follows the rules of X path development

1. Basic layout and structure

The pay statement is set up in an html-like table structure where the table cells size is determined by setting  the ColWidths value of the table (which is roughly 570 wide) in order to display the data in a viewer friendly pdf. Each ColWidth value would have an associated PdfTableCell.

NOTE: The tags are case sensitive. ColSpan will be recognized while Colspan will be ignored.

Multiple tables can be used and placed on the page in the desired location using x/y coordinates. The page is 800x570 in picture mode. It is helpful to have multiple tables if you plan on some content being the same on every page. This is done using the UpdateMasterPage variable.

<PdfTable xPos="20" yPos="735" ColWidths="81,81,81,82,82,82,81" Border="No" UpdateMasterPage="True" >
 <PdfTableRow>
     <PdfTableCell></PdfTableCell>

If your pay statement has multiple line items and as a chance of spanning more than one page you'd use the following table structure

<PdfTableMultiPage x1Pos="20" x2Pos="0" y1Pos="0" y2Pos="735" ColWidths="350,150" Border="No" UpdateMasterPage="True" >

2. Adding images

<PdfImageFromDisk xPos="235" yPos="650" height="125" width="200" imageBase64="{$logo_base64}" UpdateMasterPage="False"/>
<xsl:variable name="logo_base64">/9j/4AAQSkZJRg…</xsl:variable>

3. Using variables for multiple language support

<!-- language preference can be set up in the xml or chosen by the user via the ui -->

<xsl:variable name="Culture" select="/G_EMP_DATA/CULTURE" />

<!-- <xsl:variable name="Culture" select="user:CurrentCulture()" /> passed by ui -->

       <xsl:variable name="lblIMPORTANTMESSAGES">
              <xsl:choose>
                     <xsl:when test="$Culture='fr-CA'">MESSAGES IMPORTANTS:</xsl:when>
                     <xsl:when test="$Culture='es-MX'">IMPORTANT MESSAGES:</xsl:when>
                     <xsl:otherwise>IMPORTANT MESSAGES:</xsl:otherwise>
              </xsl:choose>
       </xsl:variable>
<xsl:variable name="lblRegister">
              <xsl:choose>
                     <xsl:when test="$Culture='fr-CA'">No de registre:</xsl:when>
                     <xsl:when test="$Culture='es-MX'">Register #:</xsl:when>
                     <xsl:otherwise>Register #:</xsl:otherwise>
              </xsl:choose>
       </xsl:variable>


the variable is then placed in the appropriate location by referencing it like this:

<xsl:value-of select="$lblRegister" />
*Note – xml/xslt is case sensitive so lblregister would not be recognized

4. Using IF or CHOOSE to affect what is displayed

You can see from the previous sample how xsl:choose allows multiple conditions. In the below sample xsl:if is used to only display a template/section of the pay statement if the xml is present.

<PdfTableRow>        
    <PdfTableCell Border="No" ColSpan="4">
    <xsl:if test="SICK_LEAVE_HOURS/pto_accr">
        <PdfTableNested ColWidths="140,140" Border="No">
            <xsl:apply-templates select="SICK_LEAVE_HOURS" />
        </PdfTableNested>
    </xsl:if>
    </PdfTableCell>

       <PdfTableCell Border="No" ColSpan="4">
       <xsl:if test="COVID_LEAVE_HOURS/pto_accr">
        <PdfTableNested ColWidths="140,140" Border="No">
            <xsl:apply-templates select="COVID_LEAVE_HOURS" />
        </PdfTableNested>
       </xsl:if>
   </PdfTableCell>
</PdfTableRow>