Yes, you can do this in XSLT.
Pass the system date as a parameter to the stylesheet. This is easier
than getting it by calling an extension function, and more portable.
You would be better off if you stored dates in ISO format as yyyy-mm-dd,
but you can easily transform them using the substring() function.
It's worth looking at the www.exslt.org library for date and time
handling functions.
There are two ways to produce multiple output files. One is to use
vendor extensions - many products have this feature, with the notable
exception of MSXML. The other way is to call the stylesheet once for
each output file you want to produce, with a parameter identifying the
TV channel.
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
milena schrevel
Sent: 29 October 2002 12:51
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] newbie q: xml to txt - please help!
hi all,
TASK: i want to exctract certain data from a xml-file, which
contains programdetails of several tv channels, and put it
into a txt-file (one textfile for each tvchannel). the
programm should read from the xml file the data starting from
6:00 am of the next day till 5:59 am of the day after that.
(this will be executed once a day for every following day.)
QUESTIONS: can my problem be solved with xsl/xslt, or do i
need another programminglanguage (vbscript or c)? how will
get xsl sysdate? there are 22 tvchannels in the xmlfile, for
every channel i need a different textfile. how to pass
parameter? thanx! milena schrevel
XML-FILE:
...
<RESOURCE id="EVENTLIST_AAA">
<EVENTLIST originalnetworkid="2" transportstreamid="1099"
serviceid="0x2EE5" servicename="AAA">
<EVENT eventid="0x23BB96">
<STARTTIME country="deu" date="21.09.2002" time="16:00:00" />
<DURATION country="deu" time="01:00" />
<SHORTEVENTDESC language="ger">
<EVENTNAME>News</EVENTNAME>
</SHORTEVENTDESC>
</EVENT>
<EVENT eventid="0x23BB7A">
<STARTTIME country="deu" date="21.09.2002" time="17:00:00" />
<DURATION country="deu" time="00:15" />
<SHORTEVENTDESC language="ger">
<EVENTNAME>Weather</EVENTNAME>
</SHORTEVENTDESC>
</EVENT>
</EVENTLIST>
</RESOURCE>
<RESOURCE id="EVENTLIST_BBB">
<EVENTLIST originalnetworkid="2" transportstreamid="1099"
serviceid="0x2EF3" servicename="BBB">
<EVENT eventid="0x23A6A1">................</EVENT>
</EVENTLIST>
</RESOURCE>
.........
example of output aaa.txt :
aaa 21.09.2002 16:00:00 News
aaa 21.09.2002 17:00:00 Weather
My first XSL-FILE, which does the job wihtout checking for
the dates and only for one tvchannel:(
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl =
"http://www.w3.org/1999/XSL/Transform" version > = "1.0" >
<xsl:output method = "text" media-type = "text/plain"
encoding="ISO-8859-1"/> <xsl:strip-space elements="*"/>
<xsl:template match="RESOURCE[(_at_)id='EVENTLIST_AAA']">
<xsl:for-each select="EVENTLIST/EVENT">
<xsl:if test = "DURATION[(_at_)time!='00:00']">
<xsl:text>aaa </xsl:text>
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match = "STARTTIME">
<xsl:value-of select = "@date"/>
<xsl:text> </xsl:text>
<xsl:value-of select = "@time"/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match = "SHORTEVENTDESC">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match = "EVENTNAME">
<xsl:value-of select = "."/>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list