[xiph-commits] r8974 - trunk/xspf/xslt
lgonze at motherfish-iii.xiph.org
lgonze at motherfish-iii.xiph.org
Tue Feb 22 17:41:11 PST 2005
Author: lgonze
Date: 2005-02-22 17:41:10 -0800 (Tue, 22 Feb 2005)
New Revision: 8974
Added:
trunk/xspf/xslt/README.txt
trunk/xspf/xslt/xspf2html.xsl
trunk/xspf/xslt/xspf2m3u.xsl
trunk/xspf/xslt/xspf2smil.xsl
trunk/xspf/xslt/xspf2soundblox.xsl
Log:
Check in from loose files on gonze.com/xspf.
Added: trunk/xspf/xslt/README.txt
===================================================================
--- trunk/xspf/xslt/README.txt 2005-02-23 01:40:12 UTC (rev 8973)
+++ trunk/xspf/xslt/README.txt 2005-02-23 01:41:10 UTC (rev 8974)
@@ -0,0 +1,2 @@
+These are XSLT transformations from XSPF to other formats. These were
+targetted at XSPF version 0, draft 8.
Added: trunk/xspf/xslt/xspf2html.xsl
===================================================================
--- trunk/xspf/xslt/xspf2html.xsl 2005-02-23 01:40:12 UTC (rev 8973)
+++ trunk/xspf/xslt/xspf2html.xsl 2005-02-23 01:41:10 UTC (rev 8974)
@@ -0,0 +1,212 @@
+<!--
+ Convert XSPF to HTML.
+ Author: Lucas Gonze <lucas at gonze.com>
+ Copyright 2004 Lucas Gonze.
+ Licensed under version 2.0 of the Gnu General Public License.
+-->
+<xsl:stylesheet version = '1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ xmlns:xspf="http://xspf.org/ns/0/"
+ >
+
+ <xsl:output method="html" indent="yes"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+
+ <xsl:if test="string(//xspf:title)">
+ <title>
+ <xsl:value-of select="//xspf:title"/>
+ </title>
+ </xsl:if>
+
+ <link rel='stylesheet' type='text/css' media='screen' href='http://www.w3.org/StyleSheets/Core/Modernist' />
+ <style type="text/css">
+dl {
+ margin-bottom: 5px;
+}
+
+.track {
+}
+
+.location {
+}
+
+.creator {
+}
+
+.top {
+}
+
+.duration {
+}
+
+.trackList {
+}
+
+.info {
+}
+
+.annotation {
+}
+
+.attribution {
+}
+
+.image {
+}
+
+.meta {
+}
+
+.license {
+}
+
+.trackNum {
+}
+
+.date {
+}
+
+.identifier {
+}
+
+.link {
+}
+
+
+ </style>
+
+ </head>
+
+ <body>
+
+ <xsl:if test="string(//xspf:title)">
+ <h1>
+ <xsl:value-of select="//xspf:title"/>
+ </h1>
+ </xsl:if>
+
+ <dl class="top">
+ <xsl:apply-templates select="*" />
+ </dl>
+
+ </body>
+ </html>
+ </xsl:template>
+
+ <!-- all href elements -->
+ <xsl:template match="xspf:location|xspf:info|xspf:license|xspf:link|xspf:meta">
+ <xsl:if test="string(.)">
+ <dt>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <xsl:value-of select="name(.)"/>
+ </dt>
+ <dd>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+
+ <!-- fixme: if there is a @rel or @property attribute, display
+ and link to it. We'll get an @rel if the current item is
+ xspf:link and @property if current item is xspf:meta. -->
+
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="." />
+ </xsl:attribute>
+ <xsl:value-of select="." />
+ </a>
+
+ </dd>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- all image elements -->
+ <xsl:template match="xspf:image">
+ <xsl:if test="string(.)">
+ <dt>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <xsl:value-of select="name(.)"/>
+ </dt>
+ <dd>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <img>
+ <xsl:attribute name="src">
+ <xsl:value-of select="." />
+ </xsl:attribute>
+ </img>
+ </dd>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- all text elements -->
+ <xsl:template match="xspf:annotation|xspf:trackNum|xspf:creator|xspf:identifier|xspf:date|xspf:duration|xspf:title">
+ <xsl:if test="string(.)">
+ <dt>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <xsl:value-of select="name(.)"/>
+ </dt>
+ <dd>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <xsl:value-of select="." />
+ </dd>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- ordered lists -->
+ <xsl:template match="xspf:trackList|xspf:attribution">
+ <xsl:if test="string(.)">
+ <dt>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <xsl:value-of select="name(.)"/>
+ </dt>
+ <dd>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+
+ <ol>
+ <xsl:for-each select="*">
+ <li>
+ <xsl:apply-templates select="." />
+ </li>
+ </xsl:for-each>
+ </ol>
+
+ </dd>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- track element is an oddball that needs its own template -->
+ <xsl:template match="xspf:track">
+ <dl>
+ <xsl:attribute name="class">
+ <xsl:value-of select="name(.)"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="*"/>
+ </dl>
+ </xsl:template>
+
+ <!-- top-level title element is an oddball that needs its own template -->
+ <xsl:template match="//xspf:title"/>
+
+ <!-- Suppress items not accounted for in templates. Disable during debugging, enable in production.
+ -->
+ <xsl:template match="text()" />
+
+</xsl:stylesheet>
+
Added: trunk/xspf/xslt/xspf2m3u.xsl
===================================================================
--- trunk/xspf/xslt/xspf2m3u.xsl 2005-02-23 01:40:12 UTC (rev 8973)
+++ trunk/xspf/xslt/xspf2m3u.xsl 2005-02-23 01:41:10 UTC (rev 8974)
@@ -0,0 +1,20 @@
+<!--
+ xspf2m3u.xsl: transform XSPF to M3U
+ author: Lucas Gonze <lucas at webjay.org>
+-->
+<xsl:stylesheet version = '1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ xmlns:xspf="http://xspf.org/ns/0/">
+
+ <xsl:output method="text"/>
+ <xsl:template match="/">
+
+ <xsl:for-each select="//xspf:trackList/xspf:track/xspf:location">
+ <xsl:value-of select="."/>
+ <xsl:text>
+</xsl:text>
+ </xsl:for-each>
+
+ </xsl:template>
+
+</xsl:stylesheet>
Added: trunk/xspf/xslt/xspf2smil.xsl
===================================================================
--- trunk/xspf/xslt/xspf2smil.xsl 2005-02-23 01:40:12 UTC (rev 8973)
+++ trunk/xspf/xslt/xspf2smil.xsl 2005-02-23 01:41:10 UTC (rev 8974)
@@ -0,0 +1,76 @@
+<!--
+ Convert XSPF to SMIL.
+ Author: Lucas Gonze <lucas at gonze.com>
+
+ Copyright 2004 Lucas Gonze. Licensed under version 2.0 of the Gnu
+ General Public License.
+-->
+<xsl:stylesheet version = '1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ xmlns:xspf="http://xspf.org/ns/0/"
+ >
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <smil>
+ <body>
+ <seq>
+ <xsl:apply-templates select="*" />
+ </seq>
+ </body>
+ </smil>
+ </xsl:template>
+
+ <xsl:template match="//xspf:annotation" ></xsl:template>
+ <xsl:template match="//xspf:creator" ></xsl:template>
+ <xsl:template match="//xspf:info" ></xsl:template>
+ <xsl:template match="//xspf:location" ></xsl:template>
+ <xsl:template match="//xspf:identifier" ></xsl:template>
+ <xsl:template match="//xspf:image" ></xsl:template>
+ <xsl:template match="//xspf:link" ></xsl:template>
+ <xsl:template match="//xspf:meta" ></xsl:template>
+ <xsl:template match="//xspf:date" ></xsl:template>
+ <xsl:template match="//xspf:attribution" ></xsl:template>
+ <xsl:template match="//xspf:license" ></xsl:template>
+
+ <xsl:template match="//xspf:trackList">
+ <xsl:apply-templates select="*" />
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track">
+ <xsl:apply-templates select="xspf:location"/>
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:location" >
+ <audio>
+ <xsl:attribute name="src">
+ <xsl:value-of select="." />
+ </xsl:attribute>
+
+ <xsl:if test="string(../xspf:annotation)">
+ <xsl:attribute name="title">
+ <xsl:value-of select="../xspf:annotation"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ </audio>
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:image" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:annotation" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:creator" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:title" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:album" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:trackNum" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:duration" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:identifier" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:info" ></xsl:template>
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:meta" ></xsl:template>
+
+ <!-- Suppress items not accounted for in templates. Disable during debugging, enable in production.
+ -->
+ <xsl:template match="text()" />
+
+</xsl:stylesheet>
+
Added: trunk/xspf/xslt/xspf2soundblox.xsl
===================================================================
--- trunk/xspf/xslt/xspf2soundblox.xsl 2005-02-23 01:40:12 UTC (rev 8973)
+++ trunk/xspf/xslt/xspf2soundblox.xsl 2005-02-23 01:41:10 UTC (rev 8974)
@@ -0,0 +1,65 @@
+<!--
+ Convert XSPF to Soundblox data format.
+ Author: Lucas Gonze <lucas at gonze.com>
+ Copyright 2004 Lucas Gonze.
+ Licensed under version 2.0 of the Gnu General Public License.
+
+ A proof of concept, not robust yet. Needs work by someone more
+ familiar with Soundblox than I am.
+-->
+<xsl:stylesheet version = '1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ xmlns:xspf="http://xspf.org/ns/0/">
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+
+ <soundbloxdata>
+ <customize autostart="false" startopen="true"/>
+ <playlist>
+
+ <xsl:if test="string(//xspf:title)">
+ <xsl:attribute name="name">
+ <xsl:value-of select="//xspf:title"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="*"/>
+
+ </playlist>
+ </soundbloxdata>
+
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track">
+ <track>
+ <xsl:apply-templates select="*"/>
+ </track>
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:location">
+ <xsl:if test="string(.)">
+ <!-- fixme: test extension to confirm it is an mp3 -->
+ <mp3url><xsl:value-of select="."/></mp3url>
+ <downloadurl><xsl:value-of select="."/></downloadurl>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:image">
+ <xsl:if test="string(.)">
+ <imageurl><xsl:value-of select="."/></imageurl>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="//xspf:trackList/xspf:track/xspf:annotation">
+ <xsl:if test="string(.)">
+ <comments><xsl:value-of select="."/></comments>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- Suppress items not accounted for in templates. Disable during
+ debugging, enable in production. -->
+ <xsl:template match="text()"/>
+
+</xsl:stylesheet>
More information about the commits
mailing list