[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [XSL] Get time and data

Subject: Re: [XSL] Get time and data
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Fri, 09 Mar 2001 10:09:57 +0100
xsl time
KOBILY <KOBILY@xxxxxxxx> wrote:
> Hi !!!!
> 
> I need to get the data and time but I do not want to use javascript, 
> `perl, php, etc.
> Could I get the date and time using xsl ?
> 
> Thanks.

There is currently no way to do this from within an XSL sheet.
I use external tools to write the desired information into a
XML file and get the value into the XSL sheet by using document():

Command line frame (requires Unix toolset, Korn shell or bash):

cat >time.xml <<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<time>$(date "+%Y-%m-%d %H:%M:%S")</time>
EOF
saxon -o $3 $1 $2

XSL snippet:

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

  <xsl:variable name="time" select="document('time.xml')/time"/>
...

This reads a nicely formatted timestamp into the $time variable.
If you need year, month, day etc. separately, you could structure the
time.xml file:

cat >time.xml <<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<time>
  <year>$(date "+%Y")</year>
  <month>$(date "+%m")</month>
   ...
</time>
EOF


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

  <xsl:variable name="time" select="document('time.xml')/time"/>

  ... 
    <my-year><xsl:value-of select="$time/year"/></my-year>
  ...

Of course, if you work on Windows, creating time.xml may be a
greater challenge. I installed an Unix toolset on my windows
machine (the example above was developed on windows!). There are
several, you might want to check out the free CYGWIN toolkit
at http://www.cygwin.org . Alternatively, you can use WSH, Visual
Basic, Perl or write a java program.

HTH
J.Pietschmann

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.