[XSLT] convertir un document XHTML a RDF
Bonjour, j'aimerais savoir comment transformer un document XHTML annoté en RDF en utilisant XSLT, je sais que je dois utiliser Xpath, mais de quelle facon?
Voici ce que j'ai de fait jusqu'à maintenant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xls="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="/xhtml:html" >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"
<rdf:Description rdf:about="http://mondocument.org">
<dc:title><xsl:value-of select="html:head/html :title"/></dc:title>
</rdf:Description>
</rdf:RDF>
</xsl:template>
</xsl:stylesheet> |
Voici ce que le document doit me donner en html:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <html>
<body><pre>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<rdf:Description rdf:about="http://mondocument.org">
<title
xmlns="http://purl.org/dc/elements/1.1/">
le titre de mon document
</title >
</rdf:Description>
</rdf:RDF>
</pre></body></html> |
voici le fichier de départ
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
<meta name="DC.title" content="le titre de mon document" />
<meta name="DC.description" content="la description" />
<meta name="DC.date" content="2007-01-03" />
<meta name="DC.format" content="text/html" />
<meta name="DC.language" content="fr" />
<meta name="DC.publisher" content="CSDL" />
<title>un petit document</title>
</head>
<body>
<p>Ceci est un document XHTML annoté avec Dublin Core.</p>
</body>
</html> |