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:
voila mon programme XSLT :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <?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>
et mon programme XHTML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <?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>
mes sa donne pas le bon résultat , sa me donne :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?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>
merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 <?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>
Partager