Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1501 connectés 

  FORUM HardWare.fr
  Programmation
  XML/XSL

  XHTML (Dublin Core) + XSLT -> RDF

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

XHTML (Dublin Core) + XSLT -> RDF

n°1771396
EmperorCad​avre
Posté le 08-08-2008 à 22:15:37  profilanswer
 

Bonjour,
           j'aimerais savoir comment transformer un document XHTML annoté en "Dublin Core" (RDF) en utilisant XSLT. J'ai presque trouvé la solution mais j'éprouve encore quelques difficultés. Voici mon fichier xhtml source:
 

Code :
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <?xml-stylesheet type="text/xsl" href="Test.xslt"?>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
  8. <meta name="DC.title" content="le titre de mon document" />
  9. <meta name="DC.description" content="http://mondocument.org" />
  10. <title>Un petit document</title>
  11. </head>
  12. <body>
  13. <p>Test</p>
  14. </body>
  15. </html>


 
Et ceci est mon fichier XSLT:

Code :
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  3. <xsl:output method="html" version="1.0" encoding="ISO-8859-1" indent="yes"/>
  4. <xsl:template match="xhtml:link">
  5. </xsl:template>
  6. <xsl:template match="xhtml:link">
  7. <html>
  8. <body><pre>
  9. <?xml version="1.0" encoding="ISO-8859-1" ?>
  10. <rdf:RDF
  11. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
  12. <xsl:if test="substring-before(@rel,'.') = 'schema' ">
  13. <xsl:for-each select="../xhtml:meta[substring-before(@name,'.') = substring-after(current()/@rel,'.')]">
  14. <rdf:Description rdf:about="http://mondocument.org">
  15. <<xsl:value-of select="substring-after(./@name,'.')"/>
  16. xmlns="<xsl:value-of select="../xhtml:link[substring-after(@rel,'.')=substring-before(current()/@name,'.')]/@href"/>">
  17. <xsl:value-of select="@content"/>
  18. </<xsl:value-of select="substring-after(./@name,'.')"/> >
  19. </rdf:Description>
  20. </xsl:for-each>
  21. </xsl:if>
  22. </rdf:RDF>
  23. </pre></body>
  24. </html>
  25. </xsl:template>
  26. </xsl:stylesheet>


 
Et mon problème est que j'obtiens ceci:

Code :
  1. <?xml version="1.0" encoding="ISO-8859-1" ?>
  2. <rdf:RDF
  3. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
  4. <rdf:Description rdf:about="http://mondocument.org">
  5. <title
  6. xmlns="http://purl.org/dc/elements/1.1/">
  7. le titre de mon document
  8. </title >
  9. </rdf:Description>
  10. <rdf:Description rdf:about="http://mondocument.org">
  11. <description
  12. xmlns="http://purl.org/dc/elements/1.1/">
  13. http://mondocument.org
  14. </description >
  15. </rdf:Description>
  16. </rdf:RDF>


 
au lieu de ceci:

Code :
  1. <?xml version="1.0" encoding="ISO-8859-1" ?>
  2. <rdf:RDF
  3. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
  4. <rdf:Description rdf:about="http://mondocument.org">
  5. <title
  6. xmlns="http://purl.org/dc/elements/1.1/">
  7. le titre de mon document
  8. </title >
  9. </rdf:Description>
  10. </rdf:RDF>


 
Comme vous pouvez le voir, j'obtiens à cause de mon "for-each" un double. Alors est-ce que quelqu'un a déjà rencontré ce type de problème et qu'est-ce qu'il a fait pour le régler?  :??:
 
Toute aide sera vraiment appréciée!  
EmperorCadavre

mood
Publicité
Posté le 08-08-2008 à 22:15:37  profilanswer
 

n°1771889
avander
Posté le 11-08-2008 à 11:35:55  profilanswer
 

Tu passes deux fois dans le for-each, donc c'est normal qu'il te produise deux résultats...

n°1772142
EmperorCad​avre
Posté le 11-08-2008 à 18:43:16  profilanswer
 

Salut, effectivement mon for-each, comme je l'avais mentionné plus tôt, était mon problème. Mais j'ai finalement trouvé une solution à mon problème. Même si, selon moi, elle peut paraitre comme une forme de "patchage". Mais au moins elle donne le résultat que je recherchais. Merci quand même de ton aide!  


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  XML/XSL

  XHTML (Dublin Core) + XSLT -> RDF

 

Sujets relatifs
Boost programmation multi coreProbleme particulié en xhtml/css - FIXED
[Résolu][XSLT] Utilisation de la librairie redirect[Résolu] XSLT : grouper et sommer
Multithread et core 2 duo[Resolu] Impossible de valider la page en XHTML...
W3C : utiliser HTML 4 ou XHTML 1 ?2 contenu sur la même ligne en xhtml strict
Transformation XSLT en Javascript[XSLT] Position d'un élément (élément non courant)
Plus de sujets relatifs à : XHTML (Dublin Core) + XSLT -> RDF


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR