Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-10-30
4
Medium Priority
?
343 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 80 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

Industry Leaders: 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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

705 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