summaryrefslogtreecommitdiffstats
path: root/xslt/delicious2tellico.xsl
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2014-03-03 13:46:44 +0100
committerSlávek Banko <slavek.banko@axis.cz>2014-03-03 13:46:44 +0100
commit2e02da046d3e56cdf4744f644af35ad07424f48b (patch)
treef2dcf353aa2338eae1c2ff2c41af971c580c2762 /xslt/delicious2tellico.xsl
parent3c13229d98167ae4ae0710d5eeef23fef5005bf0 (diff)
downloadtellico-2e02da046d3e56cdf4744f644af35ad07424f48b.tar.gz
tellico-2e02da046d3e56cdf4744f644af35ad07424f48b.zip
Update to upstream version 1.3.6
Diffstat (limited to 'xslt/delicious2tellico.xsl')
-rw-r--r--xslt/delicious2tellico.xsl283
1 files changed, 277 insertions, 6 deletions
diff --git a/xslt/delicious2tellico.xsl b/xslt/delicious2tellico.xsl
index e185d58..a272439 100644
--- a/xslt/delicious2tellico.xsl
+++ b/xslt/delicious2tellico.xsl
@@ -21,17 +21,41 @@
doctype-public="-//Robby Stephenson/DTD Tellico V10.0//EN"
doctype-system="http://periapsis.org/tellico/dtd/v10/tellico.dtd"/>
+<xsl:param name="item-type"/>
+
<xsl:template match="/">
<tc:tellico syntaxVersion="10">
- <tc:collection title="Delicious Library Import" type="2">
+ <!-- DL libraries can contain mixed types and right now, there's no way to do that in Tellico -->
+ <!-- so we're going to limit the export to whatever the type of the first item is -->
+ <xsl:variable name="item">
+ <xsl:choose>
+ <xsl:when test="string-length($item-type) &gt; 0">
+ <xsl:value-of select="$item-type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="local-name(library/items/child::*[1])"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:comment><xsl:text>Choosing all items of type </xsl:text><xsl:value-of select="$item"/></xsl:comment>
+
+ <xsl:variable name="type">
+ <xsl:choose>
+ <xsl:when test="$item='book'">2</xsl:when>
+ <xsl:when test="$item='movie'">3</xsl:when>
+ <xsl:when test="$item='game'">11</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <tc:collection title="Delicious Library Import">
+ <xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute>
<tc:fields>
<tc:field name="_default"/>
<tc:field flags="0" title="Amazon Link" category="General" format="4" type="7" name="amazon" i18n="true"/>
<tc:field flags="0" title="UUID" category="General" format="0" type="1" name="uuid"/>
</tc:fields>
- <xsl:for-each select="library/items/book">
- <xsl:apply-templates select="."/>
- </xsl:for-each>
+ <xsl:apply-templates select="library/items/child::*[local-name()=$item]"/>
</tc:collection>
</tc:tellico>
</xsl:template>
@@ -56,7 +80,7 @@
<xsl:otherwise>
<xsl:value-of select="@title"/>
</xsl:otherwise>
- </xsl:choose>
+ </xsl:choose>
</tc:title>
<tc:subtitle>
@@ -116,7 +140,7 @@
<tc:rating>
<!-- tellico automatically rounds down -->
- <xsl:value-of select="netrating"/>
+ <xsl:value-of select="@netrating"/>
</tc:rating>
<xsl:call-template name="split">
@@ -132,6 +156,219 @@
</tc:entry>
</xsl:template>
+<xsl:template match="movie">
+ <tc:entry>
+ <tc:uuid>
+ <xsl:value-of select="@uuid"/>
+ </tc:uuid>
+
+ <tc:amazon>
+ <xsl:if test="@asin">
+ <xsl:value-of select="concat('http://www.amazon.com/dp/',@asin,'/?tag=tellico-20')"/>
+ </xsl:if>
+ </tc:amazon>
+
+ <tc:title>
+ <xsl:call-template name="strip-title">
+ <xsl:with-param name="title" select="@title"/>
+ </xsl:call-template>
+ </tc:title>
+
+ <tc:medium>
+ <xsl:value-of select="@aspect"/>
+ </tc:medium>
+
+ <xsl:call-template name="split">
+ <xsl:with-param name="name" select="'tc:director'"/>
+ <xsl:with-param name="value" select="@director"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="split">
+ <xsl:with-param name="name" select="'tc:cast'"/>
+ <xsl:with-param name="value" select="@stars"/>
+ </xsl:call-template>
+
+ <xsl:if test="contains(@features, 'Widescreen')">
+ <tc:widescreen>true</tc:widescreen>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, 'NTSC')">
+ <tc:format i18n="true">NTSC</tc:format>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, 'PAL')">
+ <tc:format i18n="true">PAL</tc:format>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, 'SECAM')">
+ <tc:format i18n="true">SECAM</tc:format>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, 'Color')">
+ <tc:color i18n="true">Color</tc:color>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, 'Black &amp; White')">
+ <tc:color i18n="true">Black &amp; White</tc:color>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, '1.33:1')">
+ <tc:aspect-ratios>
+ <tc:aspect-ratio>1.33:1</tc:aspect-ratio>
+ </tc:aspect-ratios>
+ </xsl:if>
+
+ <xsl:if test="contains(@features, '1.85:1')">
+ <tc:aspect-ratios>
+ <tc:aspect-ratio>1.85:1</tc:aspect-ratio>
+ </tc:aspect-ratios>
+ </xsl:if>
+
+ <tc:audio-tracks>
+ <xsl:if test="contains(@features, 'Dolby')">
+ <tc:audio-track i18n="true">Dolby</tc:audio-track>
+ </xsl:if>
+ <xsl:if test="contains(@features, 'DTS')">
+ <tc:audio-track i18n="true">DTS</tc:audio-track>
+ </xsl:if>
+ </tc:audio-tracks>
+
+ <xsl:choose>
+ <xsl:when test="contains(@genre, 'Region 1')">
+ <tc:region i18n="true">Region 1</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 2')">
+ <tc:region i18n="true">Region 2</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 3')">
+ <tc:region i18n="true">Region 3</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 4')">
+ <tc:region i18n="true">Region 4</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 5')">
+ <tc:region i18n="true">Region 5</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 6')">
+ <tc:region i18n="true">Region 6</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 7')">
+ <tc:region i18n="true">Region 7</tc:region>
+ </xsl:when>
+ <xsl:when test="contains(@genre, 'Region 8')">
+ <tc:region i18n="true">Region 8</tc:region>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:call-template name="split">
+ <xsl:with-param name="name" select="'tc:genre'"/>
+ <xsl:with-param name="value" select="@genre"/>
+ <xsl:with-param name="i18n" select="true()"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="split">
+ <xsl:with-param name="name" select="'tc:studio'"/>
+ <xsl:with-param name="value" select="@publisher"/>
+ </xsl:call-template>
+
+ <tc:running-time>
+ <xsl:value-of select="@minutes"/>
+ </tc:running-time>
+
+ <tc:certification>
+ <xsl:value-of select="concat(@mpaarating, ' (US)')"/>
+ </tc:certification>
+
+ <tc:year>
+ <xsl:call-template name="year">
+ <xsl:with-param name="value" select="@theatricalDate"/>
+ </xsl:call-template>
+ </tc:year>
+
+ <tc:pur_price>
+ <xsl:value-of select="@price"/>
+ </tc:pur_price>
+
+ <tc:pur_date>
+ <xsl:value-of select="@purchaseDate"/>
+ </tc:pur_date>
+
+ <tc:rating>
+ <!-- tellico automatically rounds down -->
+ <xsl:value-of select="@netrating"/>
+ </tc:rating>
+
+ <xsl:call-template name="split">
+ <xsl:with-param name="name" select="'tc:nationality'"/>
+ <xsl:with-param name="value" select="@country"/>
+ </xsl:call-template>
+
+ <tc:plot>
+ <xsl:value-of select="description"/>
+ </tc:plot>
+ </tc:entry>
+</xsl:template>
+
+<xsl:template match="game">
+ <tc:entry>
+ <tc:uuid>
+ <xsl:value-of select="@uuid"/>
+ </tc:uuid>
+
+ <tc:amazon>
+ <xsl:if test="@asin">
+ <xsl:value-of select="concat('http://www.amazon.com/dp/',@asin,'/?tag=tellico-20')"/>
+ </xsl:if>
+ </tc:amazon>
+
+ <tc:title>
+ <xsl:value-of select="@title"/>
+ </tc:title>
+
+ <tc:platform>
+ <xsl:value-of select="@platform"/>
+ </tc:platform>
+
+ <tc:certification>
+ <xsl:value-of select="@esrbrating"/>
+ </tc:certification>
+
+ <xsl:call-template name="split">
+ <xsl:with-param name="name" select="'tc:genre'"/>
+ <xsl:with-param name="value" select="@genre"/>
+ <xsl:with-param name="i18n" select="true()"/>
+ </xsl:call-template>
+
+ <tc:pur_price>
+ <xsl:value-of select="@price"/>
+ </tc:pur_price>
+
+ <tc:pur_date>
+ <xsl:value-of select="@purchaseDate"/>
+ </tc:pur_date>
+
+ <tc:year>
+ <xsl:call-template name="year">
+ <xsl:with-param name="value" select="@published"/>
+ </xsl:call-template>
+ </tc:year>
+
+ <tc:rating>
+ <!-- tellico automatically rounds down -->
+ <xsl:value-of select="@netrating"/>
+ </tc:rating>
+
+ <tc:publisher>
+ <xsl:value-of select="@publisher"/>
+ </tc:publisher>
+
+ <tc:description>
+ <xsl:value-of select="description"/>
+ </tc:description>
+
+ </tc:entry>
+</xsl:template>
+
<xsl:template name="split">
<xsl:param name="name"/>
<xsl:param name="value"/>
@@ -161,4 +398,38 @@
<xsl:value-of select="substring($numbers, string-length($numbers)-3, 4)"/>
</xsl:template>
+<xsl:template name="strip-title">
+ <xsl:param name="title"/>
+ <xsl:param name="chars" select="'[('"/>
+ <xsl:choose>
+ <xsl:when test="string-length($chars) = 0">
+ <xsl:value-of select="normalize-space($title)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="strip-title">
+ <xsl:with-param name="title">
+ <xsl:call-template name="str-before">
+ <xsl:with-param name="value1" select="$title"/>
+ <xsl:with-param name="value2" select="substring($chars,1,1)"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name="chars" select="substring($chars,2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="str-before">
+ <xsl:param name="value1"/>
+ <xsl:param name="value2"/>
+ <xsl:choose>
+ <xsl:when test="string-length($value2) &gt; 0 and contains($value1, $value2)">
+ <xsl:value-of select="substring-before($value1, $value2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
</xsl:stylesheet>