Solved

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

Posted on 2003-10-30
4
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

630 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