Solved

How can i print system date in my xsl fo document?

Posted on 2003-10-30
4
314 Views
Last Modified: 2013-11-18
How can i print system date in my xsl fo document?

i want to display system date in my xsl-fo document(i mean in pdf document).

i am using only xsl.
and a formatter from antenna house?

can anybody know me how can i display system date in my pdf document.

i can use java script also.


regards
vihar123
0
Comment
Question by:vihar123
  • 2
4 Comments
 
LVL 3

Expert Comment

by:evedder
ID: 9654357
I generate the xsl with fop (a framework of apache) and print the date like this...

// get the date and time of system
                      Calendar calendario = Calendar.getInstance();
                       String fecha =  calendario.getCalendar.DAY_OF_MONTH)         + "/" +
calendario.get(Calendar.MONTH) + "/" +
calendario.get(Calendar.YEAR) + ", " +
calendario.get(Calendar.HOUR_OF_DAY) + ":" +
calendario.get(Calendar.MINUTE);

 
//Print the variable fecha that contains the system date and time in the foot of the page

dos.writeBytes("<fo:static-content flow-name=\"pie_pagina\" >");
dos.writeBytes("<fo:table>");
dos.writeBytes("<fo:table-column column-Width=\"100mm\"/>");
dos.writeBytes("<fo:table-column column-width=\"95mm\"/>");
dos.writeBytes(" <fo:table-body>");
dos.writeBytes(" <fo:table-row>");
dos.writeBytes(" <fo:table-cell >");
dos.writeBytes("<fo:block font-weight=\"bold\" font-size=\"6pt\"  space-before.optimum=\"10pt\" text-align=\"start\">Fecha: " + fecha + "</fo:block>");                
dos.writeBytes(" </fo:table-cell >");
dos.writeBytes(" <fo:table-cell >");
dos.writeBytes(" <fo:block font-weight=\"bold\" font-size=\"6pt\"  space-before.optimum=\"10pt\" text-align=\"end\">Hoja <fo:page-number/> de <fo:page-number-citation ref-id=\"fin_docto\"/></fo:block>");              
dos.writeBytes("                                               </fo:table-cell >");
dos.writeBytes("                                   </fo:table-row>");
dos.writeBytes("                       </fo:table-body>");
dos.writeBytes("            </fo:table>");
dos.writeBytes("</fo:static-content>");

 


dos is a DataOutputStream

i hope it helps you!
0
 
LVL 3

Expert Comment

by:evedder
ID: 9654360
sorry for double comment, that is code in java
0
 
LVL 3

Expert Comment

by:makc
ID: 9680868
assuming xslt transforms xml into xhtml, dirty way to do it on the client site would be to put something like this

<SPAN ID=ABC></SPAN><SCRIPT>setTimeout("ABC.innerText=Date()",1000)</SCRIPT>

in the plase where you wand the date in your xslt.
0
 
LVL 2

Accepted Solution

by:
praveen79 earned 20 total points
ID: 9681388
Hi,

there are lot of ways for getting system date.

for example in ur xsl file:

<?xml version="1.0" encoding="UTF-16" ?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:sg="http://www.mtsite.com/XSL/Function">
<ms:script language="JScript" implements-prefix="sg">
<![CDATA[

function systemDate()
             {
            
        var d = new Date();
        var date;
        date = d.getFullYear() + '-' + (d.getMonth() + 1)  + '-' + d.getDate();
        return(date);      
               }
]]>
</ms:script>


and call it like form your template as:

<xsl:value-of select="sg:systemDate()" />


Hope it works.


kind regards
vihar


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
From XSL to Word - How add a page break? 5 29
Forbidden errors 5 124
Field that has HTML displays the code instead of the text in html 16 63
Problem to echo 6 82
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now