🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.text.xml
Article #10142

Re: Parser une feuille de Styles.

#10142
From: Rapha�l THERY
Date: Tue, 12 Dec 2000 08:24
100 lines
4742 bytes
    Une fois de plus l'information fournie est tr�s enrichissante ... merci
!

Par contre je n'ai pas tr�s bien compris l'histoire du param�tre.
Quand je fais un
<xsl:template name="Traduction">
   <xsl:param name="terme" select="string()" />

cela signifie que lors de l'appel au template (<xsl:call-template>),
si je n'ai pas pr�cis� de param (avec <xsl:with-param name="terme" ....)
donc de valeur,
il prend par d�faut la valeur string() du <b>noeud courant</b> ..?

Rapha�l

Tom. <ptittom@free.fr> a �crit dans le message :
dvg319.4v4.ln@ptittom.free.fr...
> In article <GE0Z5.1706$g53.5464091@nnrp2.proxad.net>, "Rapha�l THERY"
> <raphael.thery@nordnet.fr> wrote:
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:param name="lang" select="'english'"/>
> > <xsl:variable name="Dico" select="document('messages.xml')" />
> >
> > <!-- REGLE GENERALE : DUPLICATION DE L'ARBRE A L'IDENTIQUE file://-->
> > <xsl:template match="node()|@*">
> >   <xsl:copy><xsl:apply-templates select="node()|@*" /></xsl:copy>
> > </xsl:template>
>
> Il faut quand m�me s�lectionner les noeuds de texte !
> <xsl:template match="node()|@*">
>   <xsl:copy>
>     <xsl:apply-templates select="node()|@*|text()"/>
>   </xsl:copy>
> </xsl:template>
> Si tu veux recopier les commentaires et PI, il faut s�lectionner aussi
> comment() et processing-instruction().
>
> > <!-- REGLE FINE : IMG ayant l'attribut ALT file://-->
> > <xsl:template match="img[@alt]">
> > <xsl:copy>
> >   <xsl:apply-templates select="@*" />
> >
> >   <xsl:attribute name="alt">
> >     <xsl:call-template name="Traduction">
> >       <xsl:with-param name="terme"><xsl:value-of
> > select="@alt"/></xsl:with-param>
> >     </xsl:call-template>
> >   </xsl:attribute>
> >
> >   <xsl:apply-templates/>
> > </xsl:copy>
> > </xsl:template>
>
> Contente toi de "matcher" l'attribut, ce n'est pas "une image qui a un
> attribut alt" que tu traduis, c'est "l'attribut alt d'une image" :
> <xsl:template match="@alt"><!-- ou match="img/@alt" -->
>   <xsl:attribute name="alt">
>     <xsl:call-template name="Traduction">
>       <xsl:with-param name="terme" select="string()"/>
>     </xsl:call-template>
>   </xsl:attribute>
> </xsl:template>
>
> > <!-- REGLE FINE : contenu de TD et de TH file://-->
> > <xsl:template match="th/text()|td/text()">
>
> Tu ne traduis pas tous les noeuds de texte ? Enfin, � ta convenance.
>
> >   <xsl:call-template name="Traduction">
> >     <xsl:with-param name="terme"><xsl:value-of
> >     select="."/></xsl:with-param>
>
> Reprendre l'exemple ci-dessus : select="string()", mais il y a en fait
> plus simple, sans xsl:with-param.
>
> > <!-- TRADUCTION file://-->
> > <xsl:template name="Traduction">
> >   <xsl:param name="terme" />
>
> Met une valeur par d�faut :
> <xsl:param name="terme" select="string()"/>
> Avec �a, pas besoin des xsl:with-param pr�c�dents, la valeur par d�faut
> est celle qu'il nous faut (pas forc�ment dans tous les cas alors
> laissons ca en param�tre).
>
> >     <xsl:variable name="idMot"
> > select="$Dico/messages/msg[text()=$terme]/@id"/>
> >     <xsl:variable name="motTraduit"
> >     select="$Dico/messages/msg[@id=$idMot
> > and @lang=$lang]"/>
>
> Au lieu d'utiliser $Dico/messages/msg � chaque fois, tu aurais pu
> d�clarer Dico comme ca :
> <xsl:variable name="Dico"
>      select="document('messages.xml')/messages/msg"/>
> Et tu l'utilises : $Dico[text() = $terme] par exemple.
>
> Tom.
Technical Details
Message-ID: <thlZ5.2057$dP6.3755123@nnrp4.proxad.net>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!fr.clara.net!NiOuZphide.fr.clara.net!grolier!proxad.net!feeder2.proxad.net!nnrp4.proxad.net.POSTED!not-for-mail
References: <1ROX5.921$X73.3283129@nnrp1.proxad.net> <g5ar09.sa1.ln@ptittom.free.fr> <GE0Z5.1706$g53.5464091@nnrp2.proxad.net> <dvg319.4v4.ln@ptittom.free.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII
X-Google-Thread: 114f60,2a6ed2f88cdee320
X-Google-Attributes: gid114f60,public
X-Google-ArrivalTime: 2000-12-12 00:24:59 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!fr.clara.net!NiOuZphide.fr.clara.net!grolier!proxad.net!feeder2.proxad.net!nnrp4.proxad.net.POSTED!not-for-mail
From: "Rapha�l THERY" <raphael.thery@nordnet.fr>
Newsgroups: fr.comp.text.xml
References: <1ROX5.921$X73.3283129@nnrp1.proxad.net> <g5ar09.sa1.ln@ptittom.free.fr> <GE0Z5.1706$g53.5464091@nnrp2.proxad.net> <dvg319.4v4.ln@ptittom.free.fr>
Subject: Re: Parser une feuille de Styles.
Lines: 102
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Message-ID: <thlZ5.2057$dP6.3755123@nnrp4.proxad.net>
Date: Tue, 12 Dec 2000 08:24:57 GMT
NNTP-Posting-Host: 195.115.154.77
X-Complaints-To: abuse@proxad.net
X-Trace: nnrp4.proxad.net 976609497 195.115.154.77 (Tue, 12 Dec 2000 09:24:57 CET)
NNTP-Posting-Date: Tue, 12 Dec 2000 09:24:57 CET
Organization: Guest of ProXad - France