3 if [ "x$1" == "x" ]; then
4 echo "nonametv-import-svt <xmlfile>"
6 echo "Import a datafile from Svt into the nonametv database."
11 awk 'BEGIN { p=0 } /^</ {p=1} p==1 {print}' $0 | xsltproc
- $1
14 <xsl
:stylesheet xmlns
:xsl
="http://www.w3.org/1999/XSL/Transform"
15 xmlns
:exsl
="http://exslt.org/common"
16 extension-element-prefixes
="exsl"
21 Transform an input
file as delivered from Svt into one
22 file per day with the program elements sorted by the
23 start-time of the program. All files are written to
24 the current directory. The program-element is copied
29 <xsl
:output method
="xml" indent
="yes"/>
31 <xsl
:key name
="dates" match
="program" use
="date_utc"/>
32 <xsl
:key name
="channels" match
="program" use
="channel"/>
34 <xsl
:template match
="/">
36 <xsl
:if test="count(//program[generate-id() = generate-id(key('channels', channel)[1])]) != 1">
37 <xsl
:message terminate
="yes">Wrong number of channels
</xsl
:message
>
40 <xsl
:variable name
="channel" select="//program[1]/channel/text()"/>
42 <xsl
:for-each
select="//program[generate-id() = generate-id(key('dates', date_utc)[1])]">
43 <xsl
:call-template name
="export-date">
44 <xsl
:with-param name
="date" select="date_utc/text()"/>
45 <xsl
:with-param name
="channel" select="$channel"/>
50 <xsl
:template name
="export-date">
51 <xsl
:param name
="date"/>
52 <xsl
:param name
="channel"/>
54 <exsl
:document href
="{translate($channel, ' ', '-')}_{$date}.xml"
58 omit-xml-declaration
="no">
60 <xsl
:for-each
select="//program[date_utc/text()=$date]">
61 <xsl
:sort select="start_time_utc/text()"/>
62 <xsl
:copy-of
select="."/>