[XSLT] supprimer element text
Bonjour et bonne année à tous,
Je rencontre un problème xslt je voudrais masquer xsl:text dans un arborescence de résultat xslt, j'ai beaucoup de mal à manipuler ce language. Voici mes deux fichiers
Fichier Arbo.xml
Code:
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 32 33
|
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ArboSpy.xslt"?>
<racine>
<repertoire nom="XML" date-modif="25-02-2001" heure-modif="14:12">
Ressource XML (exemples, outils, portail, spécifications...)
<repertoire nom="exemples" date-modif="25-02-2001" heure-modif="14:12">
Exemple de fichier XML
</repertoire>
<fichier nom="seminaire.xml" taille="2" unite-taille="Ko" date-modif="25-02-2001" heure-modif="09:12">
Description XML du cours CXML
</fichier>
<fichier nom="ArboSpy.xml" taille="1" unite-taille="Ko" date-modif="25-02-2001" heure-modif="14:12"/>
<repertoire nom="outils" date-modif="25-03-2001" heure-modif="18:22"/>
</repertoire>
<repertoire nom="Schema" date-modif="19-02-2001" heure-modif="19:09">
<repertoire nom="DTD" date-modif="25-02-2001" heure-modif="09:12">
Ressources sur les DTD
<repertoire nom="outils" date-modif="25-02-2001" heure-modif="19:56"/>
<fichier nom="XMLSpy35.exe" taille="8" unite-taille="Mo" date-modif="28-02-2001" heure-modif="12:12">
Version d'évaluation auto-installable
</fichier>
<fichier nom="cooktop_2_101.msi" taille="4" unite-taille="Mo" date-modif="25-02-2001" heure-modif="09:45">
CookTop (éditeur XML, XSLT, DTD) gratuit au fromat MS Installeur.
</fichier>
</repertoire>
<repertoire nom="XML Schema" date-modif="25-02-2001" heure-modif="14:12"/>
</repertoire>
<fichier nom="ebXML-Specv1-0.pdf" taille="246" unite-taille="Ko" date-modif="25-02-2001" heure-modif="14:12">
Spécification ebXML à ranger dans un répertoire.
</fichier>
</racine> |
Fichier ArboSpy.xslt
Code:
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 32 33
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- formatage de l'arboresence -->
<xsl:template match="racine">
<xsl:for-each select="child::*">
<xsl:choose>
<xsl:when test="self::fichier">
<a href="#"><xsl:value-of select="@nom"/></a><br/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@nom"/><br/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="self::*"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="repertoire">
<xsl:for-each select="child::*">
<xsl:choose>
<xsl:when test="self::fichier">
<a href="#"><xsl:value-of select="@nom"/></a><br/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@nom"/><br/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> |
Le résultat obtenu : (normallement dans le navigateur avec des leins hypertext aux noeuds fichier)
Code:
1 2 3 4 5 6 7 8 9 10 11
|
XML
exemples
seminaire.xml
ArboSpy.xml
outils
Schema
DTD
XML Schema
ebXML-Specv1-0.pdf
Spécification ebXML à ranger dans un répertoire |
Le résultat souhaité (normallement dans le navigateur avec des leins hypertext aux noeuds fichier)
Code:
1 2 3 4 5 6 7 8 9 10
|
XML
exemples
seminaire.xml
ArboSpy.xml
outils
Schema
DTD
XML Schema
ebXML-Specv1-0.pdf |
J'ai essayer en faisant dans le premier template <xsl:template match="//*">, mais ça me supprime les liens hypertext, ensuite j'ai essayé avec xsl:if du genre <xsl:if test ="node() != text()">, mais ça fonctionne pas, Comment puis-je lire test dans "l'instruction if" pour savoir ce qu'il renvoie précisément...
je présice que ces fichiers sont des tests, juste pour me permettre de manipuler ce language. Après ce test réussit j'utiliserais un fichier css, pour formater les balises.
Donc si vous pouviez m'aider pour masquer les elements text, ça sera cool !
Merci d'avance
dav79