Re: Variables dans document()

Eric van der Vlist <[email protected]>
Newsgroups gmane.text.xml.french.tech
Organization Dyomedea (http://dyomedea.com)
Message-ID <[email protected]>
Le jeudi 23 février 2006 à 15:15 +0100, [email protected] a écrit :
> 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?
Vous pouvez raisonner de manière ensembliste et non mot par mot :

<xsl:template match="liste">
        <xsl:for-each select="theme/fichier[document(.)/ARTICLE/motclefs//mot = document($article_origine)/ARTICLE/motclefs//mot">
                <p><font color="#FF0000"><b><xsl:value-of select="."/></b></p>
        </xsl:for-each>
</xsl:template>

Mais vous n'associez plus un fichier commun à un mot clé et j'avais
l'impression que c'était ce que vous vouliez faire puisque vous
affichiez "pour le mot... suivi d'une liste de fichiers".

Cordialement,

Eric van der Vlist
-- 
GPG-PGP: 2A528005
Have you ever thought about unit testing XSLT templates?
                                                     http://xsltunit.org
------------------------------------------------------------------------
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/cZFDvn+ZCpSgAURAh2sAKCSDBZf0I84KBLK/EjdG3aFf3f7WACeMB+x
TBWXhFE1gHkrwW5qM7uZRqs=
=xqCN
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.