0

I am trying to add a footer at the end of each page in my XSLT file in this format:

"Page (current page number) of (max page number) - + <timestamp DD/MM/YYYY HH:MM:SS>"

Here is a sample of my code:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

   <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>


    <xsl:template match="/">
        <html lang="en">
            <head>
                <title>AML DD Transaction Summary</title>
            </head>

            <style>

                * {
                    margin-bottom : 3px;
                }

                body {
                    font-family: Arial, Helvetica, sans-serif;
                    font-size: 10px;
                }

                .titles_parent {
                    display:inline-block;
                    width: 100%;
                }
                .titles_child {
                    float: left;
                    width: 50%;
                }

                .titles_child h2 {
                    color: grey;
                }

               .inputs_block {

                }
                .inputs_child {
                    display: inline-block;
                    margin-right: 20px;
                    vertical-align: top;
                    padding: 1px;
                }

                .input_label {
                    font-weight: bold;
                    padding: 1.5px;
                }

                .input_labelFixedWidth {
                    font-weight: bold;
                    width: 180px;
                }


                .smallWidthTextArea {
                    width: 100px !important;
                    min-height: 10px;
                    font-size: 10px;
                    border-style: solid;
                    border-width: 1px;
                    border-color: Gainsboro;
                    white-space: pre-line;
                    padding: 4px 4px 4px 4px;
                }


                .halfWidthTextArea {
                    width: 315px !important;
                    min-height: 10px;
                    font-size: 10px;
                    border-style: solid;
                    border-width: 1px;
                    border-color: Gainsboro;
                    white-space: pre-line;
                    padding: 4px 4px 4px 4px;
                }


                table {
                    border-collapse: collapse;
                    border: 1px solid black;
                    style="table-layout:fixed;
                    width:700px;
                    table-layout: fixed;

                thead.report-header {
                    display:table-header-group;
                }

                table tr th {
                    background-color: lightgrey;
                    padding: 10px 30px 10px 4px;
                    text-align: left;
                    

                }

                table tr td {
                    padding: 10px 10px 10px 4px;
                    word-wrap: break-word;
                    vertical-align: top;
               }
               
              

            </style>

            <body>
                <!-- Page 1 -->
                    <div class="titles_parent">
                        <div class="titles_child">
                            <h1>Transaction AML DD Report</h1>
                        </div>
                        <div class="titles_child">
                            <h2 style="margin-left: 250px;">//DWS</h2>
                        </div>
                    </div>


                    
                    <div class="inputs">

                        
                        <div class="inputs_block">
                            <div class="inputs_child">
                                <div class="input_label">Transaction Name:</div>
                                <div class="halfWidthTextArea">
                                    <xsl:value-of select="//AMLTransactionName"/>
                                </div>
                            </div> 
                            <div class="inputs_child">   
                                <div class="input_label">AML DD Case no:</div> 
                                <div class="halfWidthTextArea">
                                        <xsl:value-of select="//AMLUniqueNumber"/>
                                </div>
                            </div>
                        </div>


                        <!-- input block 2 -->
                        <div class="inputs_block">
                            <div class="inputs_child">
                                <div class="input_label">Alts Business Line:</div>
                                <div class="halfWidthTextArea">
                                    <xsl:value-of select="//AMLBusinessUnit"/>
                                </div>
                            </div>
                            <div class="inputs_child">
                                <div class="input_label">Transaction Type:</div>
                                <div class="halfWidthTextArea">
                                     <xsl:value-of select="//AMLTransactionType"/>
                                 </div>
                            </div>
                        </div>
                    </div>
                
                
                    <!-- Page 2-->
                    <div style="page-break-before: always;"> 
                    <h3>Risk Rating Calculator</h3>
                    <h4>Country Risk Overview</h4>
                    <div class='inputs_block'>
                        <div class='inputs_child'>
                            <div class="input_labelFixedWidth">Individual</div>
                        </div>
                        <div class="inputs_child">
                            <div class="smallWidthTextArea">
                                    <xsl:value-of select="//ORMOtherCountriesIndividualCountry"/>
                            </div>
                        </div>
                    </div>

                    <div class='inputs_block'>
                        <div class='inputs_child'>
                            <div class="input_labelFixedWidth">Entity</div>
                        </div>
                        <div class="inputs_child">
                            <div class="smallWidthTextArea">
                                <xsl:value-of select="//ORMUBODomicileCountryEntity"/>
                            </div>
                        </div>
                    </div>

                    </div>
                    
                        <!-- Page 3 -->
                        <div style="page-break-before: always;"> 
                        <div class="table">
                        <table border="1" style="font-size: 10px;"> 
                            <h4>NLS Alert details</h4> 
                            <thead class="report-header"> 
                            <tr>
                                <th style=" padding: 4px 4px 4px 4px">NLS "Record ID"</th> 
                                <th style=" padding: 4px 4px 4px 4px;">Name</th> 
                                <th style=" padding: 4px 4px 4px 4px;">NLS Alert Description</th> 
                                <th style=" padding: 4px 4px 4px 4px;">AML DD Comments</th> 
                                <th style=" padding: 4px 4px 4px 4px;">AFC Comments</th> 
                            </tr>
                            </thead>
                            <xsl:for-each select="NewDataSet/*">
                            <xsl:if test="normalize-space(AMLNLSRecordID) or normalize-space(AMLNLSAlertName) or normalize-space(AMLNLSAlertDescription) or normalize-space(AMLDDAFCComments) or normalize-space(AMLAFCComments)">

                                <tr>
                                    <td>
                                        <xsl:value-of select="AMLNLSRecordID"/>
                                    </td>
                                    <td>
                                        <xsl:value-of select="AMLNLSAlertName"/>
                                    </td>
                                    <td>
                                        <xsl:value-of select="AMLNLSAlertDescription"/>
                                    </td>
                                    <td>
                                        <xsl:value-of select="AMLDDAFCComments"/>
                                    </td>
                                    <td>
                                        <xsl:value-of select="AMLAFCComments"/>
                                    </td>
                                </tr>
                            </xsl:if>
                            </xsl:for-each>
                        </table>
                        </div>
                        </div>
                </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

I have tried adding this code below at the end of each page just before the main but it is not counting the pages correctly, the output is always "Page of 1 - 17/2/2025 14:35:13" for all pages:

<div style="text-align:center; font-size:8px; margin-top:10px;">

    <xsl:text>Page </xsl:text>
                                
    <xsl:number count="div[@style='page-break-after: always;']" level="any" format="1" />
                                    
    <xsl:text> of </xsl:text>
                                
    <xsl:value-of select="count(//div[@style='page-break-after: always;']) + 1" />
                                
    <xsl:text> - </xsl:text>
                                    
    <xsl:value-of select="format-dateTime(current-dateTime(), '[D]/[M]/[Y] [H]:[m]:[s]')" />
                            
</div>

Here is a screenshot of the output I get: enter image description here

How do I achieve the result I am after? I want it to reflect the correct total and current number of pages with a timestamp

Thanks in advance!

4
  • What is your input document to the transformation? Commented Feb 18 at 13:35
  • I use XML with the data tags defined then I use freeformatter.com/xsl-transformer.html to add my XML data to XSLT....the screenshot output is the end result Commented Feb 18 at 14:07
  • In XSLT 1.0 there is no function current-dateTime nor one named format-dateTime. Thus if you are really using an XSLT 1 processor then you need to look into potential support for EXSLT extension functions or for calls into the underlying platform (e.g. Java, .NET, PHP, Python). Commented Feb 18 at 15:27
  • 1
    Please provide a minimal reproducible example including the XML input and the expected result (as code). Commented Feb 18 at 16:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.