michelc Blog

Just <strong>another</strong> WordPress.com weblog

RDF to Html conversion

with one comment

Ce fichier permet de transformer un fil RDF en code html afin de pouvoir l’intégrer à une page web.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="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/"
  xmlns:foo="http://purl.org/rss/1.0/">
    <xsl:output method="html"/>
    <xsl:template match="/">
        <xsl:apply-templates select="/rdf:RDF/foo:channel"/>
    </xsl:template>
    <xsl:template match="/rdf:RDF/foo:channel">
        <h3><xsl:value-of select="foo:title"/></h3>
        <p><xsl:value-of select="foo:description"/></p>
        <ul>
            <xsl:apply-templates select="/rdf:RDF/foo:item"/>
        </ul>
    </xsl:template>
    <xsl:template match="/rdf:RDF/foo:item">
        <li>
            <a href="{foo:link}" title="{substring(dc:date, 0, 11)}"><xsl:value-of select="foo:title"/></a>
            <p><xsl:value-of select="foo:description" disable-output-escaping="yes" /></p>
        </li>
    </xsl:template>
</xsl:stylesheet>

(Publié à l’origine sur http://www.bigbold.com/snippets/posts/show/1164)

Written by michel

16 janvier 2006 à 3:04

Publié dans Code Snippets, html, xml

Une Réponse

Subscribe to comments with RSS.

  1. […] En configuration, les types de fils xml sont passés de 6 (atom, sommaire atom, rss2, rss1, rdf et rss0.9) à 4 (atom, rdf, rss et automatique). […]


Laisser un commentaire