Miscellaneous .NET tips, code, comments, and what-not.

Monday, March 14, 2005

RDF to ASP.NET Control: Step 1

I wanted to get my delicious links and create my own DataGrid or DataList control to put on my personal site, but I didn't want to have to download and save my del.icio.us file every time: I wanted the "live" version. In order to do that, you have to "transform" the RDF to RSS format that your delicious links are served up in, stream the result into a dataset, and bind that dataset to your web control (in my case, a DataList control). I gleaned most of this from Build an RSS DataList Control in ASP.NET.


RDF to RSS XSLT file:



<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:rss="http://purl.org/rss/1.0/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="rss|/rdf:RDF">
<feed>
<xsl:apply-templates select="channel/item|/rdf:RDF/rss:item"/>
</feed>
</xsl:template>

<xsl:template match="channel/item|/rdf:RDF/rss:item">

<item>

<title>
<xsl:value-of select="title|rss:title"/>
</title>

<link>
<xsl:value-of select="link|rss:link"/>
</link>

<description>
<xsl:value-of select="description|rss:description"/>
</description>

<subject>
<xsl:value-of select="dc:subject|rss:subject"/>
</subject>
<pubdate>
<xsl:value-of select="dc:date|rss:pubdate"/> </a>
</pubdate>
</item>
</xsl:template>

</xsl:stylesheet>

0 Comments:

Post a Comment

<< Home