Re: Variables dans document()
| Newsgroups | gmane.text.xml.french.tech |
|---|---|
| Message-ID | <[email protected]> |
OKI Parfait, ca marche nickel. Cependant j'ai un petit soucis. Imaginons : J'ai 2 fichiers article_1.xml et article_2.xml article_1.xml possède les mot clefs suivant : a,b,c article_2.xml possède les mots clefs suivant : a,b article_3.xml possède les mots clefs suivant : d Je cherche à afficher les articles qui ont des mots clefs en communs avec article_1.xml J'ai fait cela : <xsl:template match="liste"> <xsl:variable name="liste" select="."/> <xsl:for-each select="document($article_origine)/ARTICLE/motclefs//mot"> <p><font color="#FF0000"><b>Pour le mot : <xsl:value-of select="." /></b></font></p> <xsl:apply-templates select="$liste/theme/fichier[.!=$article_origine]"> <xsl:with-param name="mot_en_cours" select="."/> </xsl:apply-templates> </xsl:for-each> </xsl:template> <xsl:template match="fichier"> <xsl:param name="mot_en_cours"/> <xsl:apply-templates select="document(.)/ARTICLE/motclefs//mot[.=$mot_en_cours]"> <xsl:with-param name="fichier" select="."/> <xsl:with-param name="titre" select="document(.)/ARTICLE/id"/> </xsl:apply-templates> </xsl:template> <xsl:template match="mot"> <xsl:param name="fichier"/> <xsl:param name="titre"/> <b><xsl:value-of select="$fichier" /></b><br/> </xsl:template> Ca me retourne bien article_2.xml cependant ca me le retourne en double car ils ont 2 mots en commun. Y'a t-il moyen de virer ce double affichage? MERCI DE VOTRE AIDE > Le jeudi 23 février 2006 à 14:21 +0100, [email protected] a écrit : >> J'ai cru comprendre ca pour le changement de noeuds. Il y a moyen de >> contourner ? > Oui, en mémorisant dans une variable le noeud dont vous avez besoin, par > exemple : > > <xsl:template match="liste"> > <xsl:variable name="liste" select="."/> > <xsl:for-each > select="document($article_origine)/ARTICLE/motclefs//mot"> > > .../... > > <xsl:apply-templates select="$liste/theme/fichier"> > <xsl:with-param name="mot_en_cours" > select="$mot"/> > </xsl:apply-templates> > > Cordialement, > > Eric van der Vlist > > -- > GPG-PGP: 2A528005 > Curious about Relax NG? Read my book online. > http://books.xmlschemata.org/relaxng/ > ------------------------------------------------------------------------ > Eric van der Vlist http://xmlfr.org http://dyomedea.com > (ISO) RELAX NG ISBN:0-596-00421-4 http://oreilly.com/catalog/relax > (W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema > ------------------------------------------------------------------------ > > > -- Attached file included as plaintext by Ecartis -- > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.1 (GNU/Linux) > > iD8DBQBD/bhlDvn+ZCpSgAURAmKDAKCKvW5tOOVVJlbIl/9MFkgNlC5EsgCffZMq > P8jjbIwV8/050Qm7mDuNeqg= > =mwag > -----END PGP SIGNATURE----- > > > -- > Devenez redacteur <XML>fr et contribuez au developpement du > xml francophone (http://xmlfr.org/infos/redacteurs/) ! > > Liste de diffusion "[email protected]" (http://xmlfr.org). > > Cette liste est a votre disposition pour discuter en francais de > tout sujet technique lie a XML. > > Pour resilier votre abonnement, envoyez un message contenant > la commande "unsubscribe" a [email protected] > (mailto:[email protected]?Subject=unsubscribe) > >