[xiph-commits] r16746 - in websites/xspf.org: . ns ns/0
lgonze at svn.xiph.org
lgonze at svn.xiph.org
Fri Dec 11 12:43:42 PST 2009
Author: lgonze
Date: 2009-12-11 12:43:42 -0800 (Fri, 11 Dec 2009)
New Revision: 16746
Added:
websites/xspf.org/ns/
websites/xspf.org/ns/0/
websites/xspf.org/ns/0/XSPF.rdf
websites/xspf.org/ns/0/XSPF.xsl
websites/xspf.org/ns/0/about.xsl
Log:
XSPF->RDF using GRDDL.
Code is by Yves Raimond and copied from https://motools.svn.sourceforge.net/svnroot/motools/xspf/
See http://lists.musicbrainz.org/pipermail/playlist/2008-October/002042.html
Added: websites/xspf.org/ns/0/XSPF.rdf
===================================================================
--- websites/xspf.org/ns/0/XSPF.rdf (rev 0)
+++ websites/xspf.org/ns/0/XSPF.rdf 2009-12-11 20:43:42 UTC (rev 16746)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="about.xsl" type="text/xsl" ?>
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dataview="http://www.w3.org/2003/g/data-view#">
+ <rdf:Description rdf:about="http://xspf.org/ns/0/">
+ <dataview:namespaceTransformation
+ rdf:resource="http://xspf.org/ns/0/XSPF.xsl"/>
+ </rdf:Description>
+</rdf:RDF>
Added: websites/xspf.org/ns/0/XSPF.xsl
===================================================================
--- websites/xspf.org/ns/0/XSPF.xsl (rev 0)
+++ websites/xspf.org/ns/0/XSPF.xsl 2009-12-11 20:43:42 UTC (rev 16746)
@@ -0,0 +1,376 @@
+<xsl:transform
+ xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs ="http://www.w3.org/2000/02/rdfschema#"
+ xmlns:play ="http://xspf.org/ns/0/"
+ xmlns:mo ="http://purl.org/ontology/mo/"
+ xmlns ="http://xspf.org/ns/0/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:dct="http://purl.org/dc/terms/"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
+ >
+
+<xsl:output method="xml" indent="yes" encoding="utf-8"/>
+
+<div xmlns="http://www.w3.org/1999/xhtml">
+ <h1>Transform XSPF to MusicOntology RDF</h1>
+ <p>This document specifies how to transform a valid <a href="http://xspf.org/">XSPF</a> document into <a href="http://musicontology.com">MusicOntology</a> RDF/XML.</p>
+ <p>It is designed for use by agents who understand <a href="http://www.w3.org/TR/grddl/">GRDDL</a>, and acts as the XSPF <a href="http://www.w3.org/TR/grddl/#ns-bind">NamespaceTransformation</a>.</p>
+ <p>Based on <a href="http://libby.asemantics.com/2005/01/XSPF/">original work</a> by <a href="mailto:libby at asemantics.com">Libby Miller</a></p>
+ <p>Copyright <a href="http://moustaki.org/">Yves Raimond</a> & <a href="http://clockwerx.blogspot.com/">Daniel O'Connor</a></p>
+
+ <h2>Example</h2>
+The below XSPF playlist
+<pre>
+<?xml version="1.0" encoding="utf-8"?>
+<playlist version="1" xmlns="http://xspf.org/ns/0/">
+
+ <title>My playlist</title>
+
+ <creator>Jane Doe</creator>
+ <annotation>My favorite songs</annotation>
+ <info>http://example.com/myplaylists</info>
+ <location>http://example.com/myplaylists/myplaylist</location>
+ <identifier>magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C</identifier>
+ <image>http://example.com/img/mypicture</image>
+ <date>2005-01-08T17:10:47-05:00</date>
+ <license>http://creativecommons.org/licenses/by/1.0/</license>
+ <attribution>
+ <identifier>http://bar.com/secondderived.xspf</identifier>
+ <location>http://foo.com/original.xspf</location>
+ </attribution>
+ <link rel="http://foaf.example.org/namespace/version1">http://socialnetwork.example.org/foaf/mary.rdfs</link>
+ <meta rel="http://example.org/key">value</meta>
+ <extension application="http://example.com">
+ <clip start="25000" end="34500"/>
+ </extension>
+
+<trackList>
+
+ <track>
+
+ <location>http://example.com/my.mp3</location>
+ <identifier>magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C</identifier>
+ <title>My Way</title>
+ <creator>Frank Sinatra</creator>
+ <annotation>This is my theme song.</annotation>
+ <info>http://franksinatra.com/myway</info>
+ <image>http://franksinatra.com/img/myway</image>
+ <album>Frank Sinatra's Greatest Hits</album>
+ <trackNum>3</trackNum>
+ <duration>19200</duration>
+ <link rel="http://foaf.org/namespace/version1">http://socialnetwork.org/foaf/mary.rdfs</link>
+ <meta rel="http://example.org/key">value</meta>
+ <extension application="http://example.com">
+ <clip start="25000" end="34500"/>
+ </extension>
+
+ </track>
+
+ </trackList>
+
+
+</playlist>
+</pre>
+can be transformed into
+<pre>
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/02/rdfschema#" xmlns:play="http://xspf.org/ns/0/" xmlns:mo="http://purl.org/ontology/mo/" xmlns="http://xspf.org/ns/0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:owl="http://www.w3.org/2002/07/owl#">
+ <mo:MusicalItem rdf:about="magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C">
+ <owl:sameAs rdf:resource="http://example.com/myplaylists/myplaylist"/>
+ <rdfs:seeAlso rdf:resource="http://example.com/myplaylists"/>
+ <foaf:maker>Jane Doe</foaf:maker>
+ <dc:created>2005-01-08T17:10:47-05:00</dc:created>
+ <cc:license rdf:resource="http://creativecommons.org/licenses/by/1.0/"/>
+ <mo:license rdf:resource="http://creativecommons.org/licenses/by/1.0/"/>
+ <dc:description>My favorite songs</dc:description>
+ <mo:image rdf:resource="http://example.com/img/mypicture"/>
+ <mo:track>
+ <mo:Track rdf:about="magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C">
+ <mo:available_as rdf:resource="http://example.com/my.mp3"/>
+ <foaf:maker>Frank Sinatra</foaf:maker>
+ <dc:title>My Way</dc:title>
+ <mo:album>
+ <mo:MusicalWork>
+ <dc:title>Frank Sinatra's Greatest Hits</dc:title>
+ </mo:MusicalWork>
+ </mo:album>
+ <dc:description>This is my theme song.</dc:description>
+ <mo:image rdf:resource="http://franksinatra.com/img/myway"/>
+ <rdfs:seeAlso rdf:resource="http://franksinatra.com/myway"/>
+ </mo:Track>
+ </mo:track>
+ </mo:MusicalItem>
+</rdf:RDF>
+</pre>
+
+
+ <h2>License</h2>
+ <!-- Creative Commons License -->
+ <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.0/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a><br />
+This work is licensed under a <a rel="license"
+href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons License</a>.
+<!-- /Creative Commons License -->
+
+<!--
+
+<rdf:RDF xmlns="http://web.resource.org/cc/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<Work rdf:about="">
+ <license
+rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
+</Work>
+
+<License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <permits rdf:resource="http://web.resource.org/cc/Distribution" />
+ <requires rdf:resource="http://web.resource.org/cc/Notice" />
+ <requires rdf:resource="http://web.resource.org/cc/Attribution" />
+ <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ <requires rdf:resource="http://web.resource.org/cc/ShareAlike" />
+</License>
+
+</rdf:RDF>
+
+-->
+</div>
+
+
+<xsl:template match='play:playlist'>
+<rdf:RDF>
+ <xsl:choose>
+
+ <xsl:when test="play:identifier">
+ <xsl:call-template name="playlist">
+ <xsl:with-param name="url">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <xsl:value-of select="fn:resolve-uri(play:identifier, fn:base-uri(play:identifier))" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="play:identifier" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="play:location">
+ <xsl:call-template name="playlist">
+ <xsl:with-param name="url">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <xsl:value-of select="fn:resolve-uri(play:location, fn:base-uri(play:location))" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="play:location" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name="playlist">
+ <xsl:with-param name="url"></xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+
+ </xsl:choose>
+</rdf:RDF>
+</xsl:template>
+
+<!-- Playlist -->
+<xsl:template name="playlist">
+ <xsl:param name="url" />
+ <mo:MusicalItem rdf:about="{$url}">
+
+ <xsl:if test="play:title">
+ <dc:title><xsl:value-of select="play:title" /></dc:title>
+ </xsl:if>
+
+ <!-- Do we have two URLs which can be used for this item? -->
+ <xsl:if test="play:identifier and play:location">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <owl:sameAs rdf:resource="{fn:resolve-uri(play:location, fn:base-uri(play:location))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <owl:sameAs rdf:resource="{play:location}"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="play:info">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <rdfs:seeAlso rdf:resource="{fn:resolve-uri(play:info, fn:base-uri(play:info))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <rdfs:seeAlso rdf:resource="{play:info}" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="play:creator">
+ <foaf:maker><xsl:value-of select="play:creator" />
+ </foaf:maker>
+ </xsl:if>
+
+ <xsl:if test="play:date">
+ <dc:created><xsl:value-of select="play:date" /></dc:created>
+ </xsl:if>
+
+ <xsl:if test="play:license">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <cc:license rdf:resource="{fn:resolve-uri(play:license, fn:base-uri(play:license))}" />
+ <mo:license rdf:resource="{fn:resolve-uri(play:license, fn:base-uri(play:license))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <cc:license rdf:resource="{play:license}" />
+ <mo:license rdf:resource="{play:license}" />
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:if>
+
+ <xsl:if test="play:annotation">
+ <dc:description><xsl:value-of select="play:annotation" /></dc:description>
+ </xsl:if>
+
+ <xsl:if test="play:image">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <mo:image rdf:resource="{fn:resolve-uri(play:image, fn:base-uri(play:image))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <mo:image rdf:resource="{play:image}" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <!-- TODO: meta -->
+ <!-- TODO: version -->
+ <!-- TODO: link -->
+ <!-- TODO: attribution -->
+ <!-- TODO: extension -->
+
+ <!-- TODO: Worry about xml:base? -->
+
+ <xsl:call-template name="track-list" />
+
+
+ </mo:MusicalItem>
+</xsl:template>
+
+<!-- Track List -->
+<xsl:template name="track-list">
+ <xsl:for-each select="play:trackList/play:track">
+ <mo:track>
+ <xsl:choose>
+
+ <xsl:when test="play:identifier">
+ <xsl:call-template name="track">
+ <xsl:with-param name="id">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <xsl:value-of select="fn:resolve-uri(play:identifier, fn:base-uri(play:identifier))" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="play:identifier" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+
+ <xsl:otherwise>
+ <xsl:call-template name="track">
+ <xsl:with-param name="id">#<xsl:value-of select="generate-id(.)" /></xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </mo:track>
+ </xsl:for-each>
+</xsl:template>
+
+<!-- Track -->
+<xsl:template name='track'>
+ <xsl:param name="id" />
+
+ <mo:Track rdf:about="{$id}">
+
+ <!-- 0 or more -->
+ <xsl:if test="play:location">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <mo:available_as rdf:resource="{fn:resolve-uri(play:location, fn:base-uri(play:location))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <mo:available_as rdf:resource="{play:location}"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="play:creator">
+ <foaf:maker><xsl:value-of select="play:creator" /></foaf:maker>
+ <!-- mo:MusicArtist? -->
+ </xsl:if>
+
+ <xsl:if test="play:title">
+ <dc:title><xsl:value-of select="play:title" /></dc:title>
+ </xsl:if>
+
+ <xsl:if test="play:album">
+ <mo:album>
+ <mo:MusicalWork>
+ <dc:title><xsl:value-of select="play:album" /></dc:title>
+ </mo:MusicalWork>
+ </mo:album>
+ </xsl:if>
+
+ <xsl:if test="play:annotation">
+ <dc:description><xsl:value-of select="play:annotation" /></dc:description>
+ </xsl:if>
+
+ <xsl:if test="play:image">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <mo:image rdf:resource="{fn:resolve-uri(play:image, fn:base-uri(play:image))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <mo:image rdf:resource="{play:image}" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="play:info">
+ <xsl:choose>
+ <xsl:when test="function-available('resolve-uri') and function-available('base-uri')">
+ <rdfs:seeAlso rdf:resource="{fn:resolve-uri(play:info, fn:base-uri(play:info))}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <rdfs:seeAlso rdf:resource="{play:info}" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <!-- duration -->
+ <!-- trackNum -->
+ <!-- link -->
+ <!-- meta -->
+ <!-- extension -->
+ </mo:Track>
+</xsl:template>
+
+<!-- don't pass text thru -->
+<xsl:template match="text()|@*">
+</xsl:template>
+
+</xsl:transform>
Added: websites/xspf.org/ns/0/about.xsl
===================================================================
--- websites/xspf.org/ns/0/about.xsl (rev 0)
+++ websites/xspf.org/ns/0/about.xsl 2009-12-11 20:43:42 UTC (rev 16746)
@@ -0,0 +1,73 @@
+<xsl:transform
+ xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output method="html" indent="yes" encoding="utf-8"/>
+
+
+<xsl:template match="/">
+<div xmlns="http://www.w3.org/1999/xhtml">
+ <h1>XSPF Namespace Document</h1>
+ <p>This is the namespace of <a href="http://xspf.org">XSPF</a>.</p>
+ <p>There is <a href="http://xspf.org/xspf-v1.html">documentation</a> and a <a href="XSPF.xsl">GRDDL namespace transformation</a> available.</p>
+
+ <h2>Example XSPF</h2>
+The below is an example XSPF playlist
+<pre>
+<?xml version="1.0" encoding="utf-8"?>
+<playlist version="1" xmlns="http://xspf.org/ns/0/">
+
+ <title>My playlist</title>
+
+ <creator>Jane Doe</creator>
+ <annotation>My favorite songs</annotation>
+ <info>http://example.com/myplaylists</info>
+ <location>http://example.com/myplaylists/myplaylist</location>
+ <identifier>magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C</identifier>
+ <image>http://example.com/img/mypicture</image>
+ <date>2005-01-08T17:10:47-05:00</date>
+ <license>http://creativecommons.org/licenses/by/1.0/</license>
+ <attribution>
+ <identifier>http://bar.com/secondderived.xspf</identifier>
+ <location>http://foo.com/original.xspf</location>
+ </attribution>
+ <link rel="http://foaf.example.org/namespace/version1">http://socialnetwork.example.org/foaf/mary.rdfs</link>
+ <meta rel="http://example.org/key">value</meta>
+ <extension application="http://example.com">
+ <clip start="25000" end="34500"/>
+ </extension>
+
+<trackList>
+
+ <track>
+
+ <location>http://example.com/my.mp3</location>
+ <identifier>magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C</identifier>
+ <title>My Way</title>
+ <creator>Frank Sinatra</creator>
+ <annotation>This is my theme song.</annotation>
+ <info>http://franksinatra.com/myway</info>
+ <image>http://franksinatra.com/img/myway</image>
+ <album>Frank Sinatra's Greatest Hits</album>
+ <trackNum>3</trackNum>
+ <duration>19200</duration>
+ <link rel="http://foaf.org/namespace/version1">http://socialnetwork.org/foaf/mary.rdfs</link>
+ <meta rel="http://example.org/key">value</meta>
+ <extension application="http://example.com">
+ <clip start="25000" end="34500"/>
+ </extension>
+
+ </track>
+
+ </trackList>
+
+
+</playlist>
+</pre>
+</div>
+
+</xsl:template>
+<!-- don't pass text thru -->
+<xsl:template match="text()|@*">
+</xsl:template>
+
+</xsl:transform>
More information about the commits
mailing list