[XSLT] Convertir: XHTML a RDF
Cadavre
Messages postés
13
Date d'inscription
Statut
Membre
Dernière intervention
-
Cadavre Messages postés 13 Date d'inscription Statut Membre Dernière intervention -
Cadavre Messages postés 13 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'aimerais savoir comment transformer un document XHTML annoté en "Dublin Core" (RDF) en utilisant XSLT. Je sais que je dois aussi utiliser Xpath, mais je sais pas comment mettre tout ca place ?
Voici ce que je veux obtenir:
<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://test.org">
<title
xmlns="http://purl.org/dc/elements/1.1/">
le titre du doc
</title >
</rdf:Description>
</rdf:RDF>
</pre></body></html>
Et pour y arriver je dois mettre en place un fichier XHTML comme celui-ci:
<?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="descrip" />
<meta name="DC.date" content="2000-11-30" />
<meta name="DC.format" content="text/html" />
<meta name="DC.language" content="fr" />
<meta name="DC.publisher" content="test" />
<title>un doc</title>
</head>
<body>
<p>Document XHTML annoté avec Dublin Core</p>
</body>
</html>
Ce fichier, grâce à du XSLT transformera mon XHTML de départ en un fichier comme celui que je veux obtenir. C'est là mon problème! Comment je fais ça !???!
Et je dois, finalement, utiliser des expressions xpath pour y arriver tel "xsl:if test="substring-before". Je ne recherche pas une réponse parfaite! Mais tout exemple concret de transformation d'un fichier xhtml vers RDF grâce à du XSLT me serait vraiment précieux!
Merci d'avance pour tout!
j'aimerais savoir comment transformer un document XHTML annoté en "Dublin Core" (RDF) en utilisant XSLT. Je sais que je dois aussi utiliser Xpath, mais je sais pas comment mettre tout ca place ?
Voici ce que je veux obtenir:
<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://test.org">
<title
xmlns="http://purl.org/dc/elements/1.1/">
le titre du doc
</title >
</rdf:Description>
</rdf:RDF>
</pre></body></html>
Et pour y arriver je dois mettre en place un fichier XHTML comme celui-ci:
<?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="descrip" />
<meta name="DC.date" content="2000-11-30" />
<meta name="DC.format" content="text/html" />
<meta name="DC.language" content="fr" />
<meta name="DC.publisher" content="test" />
<title>un doc</title>
</head>
<body>
<p>Document XHTML annoté avec Dublin Core</p>
</body>
</html>
Ce fichier, grâce à du XSLT transformera mon XHTML de départ en un fichier comme celui que je veux obtenir. C'est là mon problème! Comment je fais ça !???!
Et je dois, finalement, utiliser des expressions xpath pour y arriver tel "xsl:if test="substring-before". Je ne recherche pas une réponse parfaite! Mais tout exemple concret de transformation d'un fichier xhtml vers RDF grâce à du XSLT me serait vraiment précieux!
Merci d'avance pour tout!
A voir également:
- [XSLT] Convertir: XHTML a RDF
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Convertir epub en kindle - Guide
- Convertir youtube en mp3 avec audacity - Guide
- Convertir kindle en epub - Guide
- Convertir audio en texte word - Guide
2 réponses
Je crois que je n'es pas été assez clair. Ce que je ne sais pas c'est comment faire pour inclure du XSLT dans une page XHTML pour être en mesure d'utiliser les divers meta que je déclare entre les balises <head> et </head> ??? Une fois que je sais comment faire ça le reste devrait être assez simple. Alors si quelqu'un pourrait simplement me fournir un exemple concret d'une page xhtml contenant du xslt ce serait vraiment apprécié.
Bonjour,
j'ai presque trouvé la solution à mon problème. Maintenant j'obtiens ceci:
<?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:Description rdf:about="http://mondocument.org">
<description
xmlns="http://purl.org/dc/elements/1.1/">
http://mondocument.org
</description >
</rdf:Description>
</rdf:RDF>
Le problème est que je veux obtenir ceci:
<?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>
Comme vous pouvez le voir, pour un même enregistrement j'obtiens, en quelque sorte, un doublon en affichage. Et c'est ce que je tente d'éliminer.
Voici la version de mon fichier xhtml simplifiée pour une question de clarté:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Test.xslt"?>
<!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="http://mondocument.org" />
<title>Un petit document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
Finalement, voici mon fichier xslt:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="html" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="xhtml:link">
</xsl:template>
<xsl:template match="xhtml:link">
<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#" >
<xsl:if test="substring-before(@rel,'.') = 'schema' ">
<xsl:for-each select="../xhtml:meta[substring-before(@name,'.') = substring-after(current()/@rel,'.')]">
<rdf:Description rdf:about="http://mondocument.org">
<<xsl:value-of select="substring-after(./@name,'.')"/>
xmlns="<xsl:value-of select="../xhtml:link[substring-after(@rel,'.')=substring-before(current()/@name,'.')]/@href"/>">
<xsl:value-of select="@content"/>
</<xsl:value-of select="substring-after(./@name,'.')"/> >
</rdf:Description>
</xsl:for-each>
</xsl:if>
</rdf:RDF>
</pre></body>
</html>
</xsl:template>
</xsl:stylesheet>
Mon problème vient du fait que je ne trouve pas comment obtenir ce que j'ai besoin sans utiliser un "xsl:for-each". Est-ce que quelqu'un aurait une suggestion? Ça me rendrait vraiment service!
Configuration: Windows XP Pro SP3
Firefox 3.0.1
j'ai presque trouvé la solution à mon problème. Maintenant j'obtiens ceci:
<?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:Description rdf:about="http://mondocument.org">
<description
xmlns="http://purl.org/dc/elements/1.1/">
http://mondocument.org
</description >
</rdf:Description>
</rdf:RDF>
Le problème est que je veux obtenir ceci:
<?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>
Comme vous pouvez le voir, pour un même enregistrement j'obtiens, en quelque sorte, un doublon en affichage. Et c'est ce que je tente d'éliminer.
Voici la version de mon fichier xhtml simplifiée pour une question de clarté:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Test.xslt"?>
<!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="http://mondocument.org" />
<title>Un petit document</title>
</head>
<body>
<p>Test</p>
</body>
</html>
Finalement, voici mon fichier xslt:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="html" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="xhtml:link">
</xsl:template>
<xsl:template match="xhtml:link">
<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#" >
<xsl:if test="substring-before(@rel,'.') = 'schema' ">
<xsl:for-each select="../xhtml:meta[substring-before(@name,'.') = substring-after(current()/@rel,'.')]">
<rdf:Description rdf:about="http://mondocument.org">
<<xsl:value-of select="substring-after(./@name,'.')"/>
xmlns="<xsl:value-of select="../xhtml:link[substring-after(@rel,'.')=substring-before(current()/@name,'.')]/@href"/>">
<xsl:value-of select="@content"/>
</<xsl:value-of select="substring-after(./@name,'.')"/> >
</rdf:Description>
</xsl:for-each>
</xsl:if>
</rdf:RDF>
</pre></body>
</html>
</xsl:template>
</xsl:stylesheet>
Mon problème vient du fait que je ne trouve pas comment obtenir ce que j'ai besoin sans utiliser un "xsl:for-each". Est-ce que quelqu'un aurait une suggestion? Ça me rendrait vraiment service!
Configuration: Windows XP Pro SP3
Firefox 3.0.1