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

Re: newbie question: transforming xml to txt with xslt

Subject: Re: newbie question: transforming xml to txt with xslt
From: Eike Jordan <jordan@xxxxxxxxxxxxx>
Date: Wed, 23 Oct 2002 14:49:07 +0200
xslt transform xml to text
Hello Milena,

milena schrevel wrote:
hi all, i want to exctract certain data from a xml-file, which contains programdetails of several tv channels (see a examle below), and put it into txt-files (for each tv channel one txt-file). the programm should read from the xml file the data starting from 6:00 am of the following day till 5:59 am of the day after that. i am new to xml, xsl/xslt. my question is now, if my problem can be solved with xslt only, or if i need another programminglanguage (which one?) for extracting data according the time? as there are 22 tv channels, i don´t want to write an xsl-file for each of these...is parameterpassing possible with xslt? which tool you would suggest? thanks a lot in advance! any kind of help welcome! regards, milena schrevel

xml-file: ... <RESOURCE id="EVENTLIST_XYZ"> <EVENTLIST originalnetworkid="1" transportstreamid="1089" serviceid="0x2EE3" servicename="XYZ"> <EVENT eventid="0x23BB93"> <STARTTIME country="deu" date="21.09.2002" time="16:00:00" /> <DURATION country="deu" time="01:00" /> <SHORTEVENTDESC language="ger"> <EVENTNAME>News</EVENTNAME> <EVENTTEXT></EVENTTEXT> </SHORTEVENTDESC> <EVENTGENRE genreid="GENRE_0" /> </EVENT> </EVENTLIST> </RESOURCE> ... example of output.txt : xyz 21.09.2002 16:00:00 News

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



it depends on the XML date structure wether you can handle all with *one* transformation, but guessing you TV channels are all wrapped in a "RESOURCE" element with the given structure the example below may be good enough.

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

<xsl:output method="text"/>


<xsl:template match="/"> <xsl:apply-templates/> </xsl:template>

  <xsl:template match="RESOURCE">
    <xsl:value-of select="EVENTLIST/@servicename"/><xsl:text> </xsl:text>
    <xsl:value-of select="EVENTLIST/EVENT/STARTTIME/@date"/><xsl:text> </xsl:text>
    <xsl:value-of select="EVENTLIST/EVENT/STARTTIME/@time"/><xsl:text> </xsl:text>
    <xsl:value-of select="EVENTLIST/EVENT/SHORTEVENTDESC/EVENTNAME/text()"/>
  </xsl:template>

</xsl:stylesheet>

regards
--
Eike Jordan  <jordan@xxxxxxxxxxxxx>

| FIZ CHEMIE BERLIN
| Franklin Str. 11               ------    ,__o
| 10587 Berlin                  ------   _-\_<,
|                              ------   (+)/'(+)
| Tel. : 0049-30-39977 214


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.