06 January 2006

Social Bookmarking Synchronization

I had a short discussion with Richard Cameron and Ted Kandell about how to switch from Connotea to CiteULike. Connotea can export RIS or RDF and CiteUlike imports BibTex. So I wrote a XSLT stylesheet(see below) to generate the BibTex file and imported my ~600 bookmarks from connotea (see here). Results: all my bookmarks where added but the orginal URL use a DOI identifier (instead of the pumed URL or the , so I cannot find related users share my interests. Well that was a try. At this time, I keep using Connotea although CiteULike also have nice features (it stores private PDF, authors...).

<?xml version='1.0'?>
<xsl:stylesheet
version='1.0'
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:purl='http://purl.org/rss/1.0/'
xmlns:slash='http://purl.org/rss/1.0/modules/slash/'
xmlns:content='http://purl.org/rss/1.0/modules/content/'
xmlns:connotea='http://www.connotea.org/2005/01/schema#'
xmlns:dcterms='http://purl.org/dc/terms/'
xmlns:prism='http://prismstandard.org/namespaces/1.2/basic/'
xmlns:annotate='http://purl.org/rss/1.0/modules/annotate/'
xmlns:syn='http://purl.org/rss/1.0/modules/syndication/'
xmlns:dc='http://purl.org/dc/elements/1.1/'
xmlns:taxo='http://purl.org/rss/1.0/modules/taxonomy/'
xmlns:admin='http://webns.net/mvcb/'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method='text' />


<xsl:template match='/'>
<xsl:apply-templates select='rdf:RDF'/>
</xsl:template>

<xsl:template match='rdf:RDF'>
<xsl:apply-templates select='purl:item'/>
</xsl:template>

<xsl:template match='purl:item'>
@ARTICLE{<xsl:value-of select='generate-id(.)'/>

<xsl:call-template name='make-fied'>
<xsl:with-param name='key'>TITLE</xsl:with-param>
<xsl:with-param name='value'><xsl:value-of select='purl:title'/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name='make-fied'>
<xsl:with-param name='key'>URL</xsl:with-param>
<xsl:with-param name='value'><xsl:value-of select='connotea:uri/dcterms:URI/@rdf:about'/></xsl:with-param>
</xsl:call-template>

<xsl:call-template name='make-fied'>
<xsl:with-param name='key'>author</xsl:with-param>
<xsl:with-param name='value'><xsl:for-each select='dcterms:URI/dc:creator'><xsl:value-of select='translate(.,&apos;,&apos;,&apos; &apos;)'/>,</xsl:for-each></xsl:with-param>
</xsl:call-template>


<xsl:call-template name='make-fied'>
<xsl:with-param name='key'>journal</xsl:with-param>
<xsl:with-param name='value'><xsl:for-each select='dcterms:URI/prism:publicationName'><xsl:value-of select='translate(.,&apos;,&apos;,&apos; &apos;)'/>,</xsl:for-each></xsl:with-param>
</xsl:call-template>

<xsl:call-template name='make-fied'>
<xsl:with-param name='key'>keywords</xsl:with-param>
<xsl:with-param name='value'><xsl:for-each select='dc:subject'><xsl:value-of select='translate(.,&apos;,&apos;,&apos; &apos;)'/><xsl:text> </xsl:text> </xsl:for-each></xsl:with-param>
</xsl:call-template>

<xsl:call-template name='make-fied'>
<xsl:with-param name='key'>comment</xsl:with-param>
<xsl:with-param name='value'><xsl:value-of select='purl:description'/></xsl:with-param>
</xsl:call-template>

}
</xsl:template>

<xsl:template name='make-fied'>
<xsl:param name='key'/>
<xsl:param name='value'/>
<xsl:if test='string-length(normalize-space($value))&gt;0'>
<xsl:text>,
</xsl:text>
<xsl:value-of select='$key'/>=&quot;<xsl:call-template name='tex'>
<xsl:with-param name='s'><xsl:value-of select='$value'/></xsl:with-param>
</xsl:call-template>&quot;
</xsl:if>
</xsl:template>


<xsl:template name='tex'>
<xsl:param name='s'/>
<xsl:choose>
<xsl:when test='string-length($s)&gt;1 and $s!=&apos;,&apos;'>
<xsl:call-template name='tex'>
<xsl:with-param name='s'><xsl:value-of select='substring($s,1,1)'/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name='tex'>
<xsl:with-param name='s'><xsl:value-of select='substring($s,2)'/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:when test='contains(&apos;&quot;&apos;,$s)'>&apos;</xsl:when>
<xsl:otherwise><xsl:value-of select='$s'/></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

1 comment:

  1. You can go in the other direction, because CiteULike will export to EndNote format, which Connotea will upload.

    It therefore makes most sense to use CiteULike with Connotea as backup, but I like the Connotea interface better. My hope is that the two systems will soon play nice together.

    ReplyDelete