Re: Traitement selon sous-balise

"David DAZ. Duriez" <[email protected]> Fri, 27 Jun 2008 16:31:12 +0200
Newsgroups gmane.text.xml.french.tech
Message-ID <[email protected]>
Encore merci Eric, pour tes explications, et le temps consacr=E9 =E0 m'ai=
der,
maintenant =E7a fonctionne.
Cordialement

-----Message d'origine-----
De=A0: [email protected] [mailto:[email protected]] De la=
 part
de Eric van der Vlist
Envoy=E9=A0: jeudi 26 juin 2008 23:34
=C0=A0: [email protected]
Objet=A0: [xml-tech] Re: Traitement selon sous-balise

Bonsoir,
Le jeudi 26 juin 2008 =C3=A0 11:43 +0200, David DAZ. Duriez a =C3=A9crit =
:
> Merci Eric pour ton aide, ta solution fonctionne, mais seulement dans c=
e
cas
> :
>    <_06_auteur apagenum=3D"1" pagenum=3D"1">
>       <Emph cstyle=3D"06_auteur_c">Fran=C3=A7oise</Emph>
>       <Emph cstyle=3D"07_biographie"> R=C3=A9dactrice </Emph>  </_06_au=
teur>
> Comment je pourrais adapter pour que a fonctionne galement si j'ai le c=
as
> ci-dessous (pas de sous balise), et afficher : <auteur>Franoise</auteur=
> ?
>=20
>    <_06_auteur apagenum=3D"1" pagenum=3D"1">Franoise</_06_auteur>

Il faut distinguer les deux cas :


=EF=BB=BF
=EF=BB=BF         <xsl:when
=20
test=3D"contains(translate(name(current()),$translate-from,$translate-to)=
,'aute
ur') and Emph">

              =EF=BB=BF<xsl:apply-templates/>

          </xsl:when>
          <xsl:when

=20
test=3D"contains(translate(name(current()),$translate-from,$translate-to)=
,'aute
ur')">
            <!-- ici, on est certain qu'il n'y a pas de sous =C3=A9l=C3=A9=
ments Emph
-->

=EF=BB=BF
              <auteur>
                 <xsl:value-of select=3D"."/>
              </auteur>

          </xsl:when>


Il vaudrait peut =C3=AAtre mieux en profiter pour revoir la structure glo=
bale
de la transformation.

Plut=C3=B4t que :

<xsl:template match=3D"???">

...

=EF=BB=BF         <xsl:when
=20
test=3D"contains(translate(name(current()),$translate-from,$translate-to)=
,'aute
ur')">

              =EF=BB=BF<xsl:apply-templates/>

          </xsl:when>
   ...

...

</xsl:template>=20


on pourrait avoir :


=EF=BB=BF         <xsl:template
=20
match=3D"*[contains(translate(name(current()),'AZE...','aze...'),'auteur'=
) and
Emph]">
             <!-- on ne peut malheureusement pas utiliser de variables da=
ns
un @match -->

              =EF=BB=BF<xsl:apply-templates/>

          </xsl:template>

et

=EF=BB=BF
=EF=BB=BF         <xsl:template
=20
match=3D"*[contains(translate(name(current()),'AZE...','aze...'),'auteur'=
) and
not(Emph)]">
             <!-- on ne peut malheureusement pas utiliser de variables da=
ns
un @match -->

              <auteur>
                 <xsl:value-of select=3D"."/>
              </auteur>

          </xsl:template>

Cordialement,

Eric van der Vlist
--=20
GPG-PGP: 2A528005
Did you know it? Python has now a Relax NG (partial) implementation.
                                          http://advogato.org/proj/xvif/
------------------------------------------------------------------------
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.6 (GNU/Linux)

iD8DBQBIZAssDvn+ZCpSgAURAhNfAKCNMn87ZCvdoQlyPqFB4xHO5/NyKgCeLixz
jrsZZRziJLe5iu4B9qcHB4s=3D
=3DD7mt
-----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=20
tout sujet technique lie a XML.

Pour resilier votre abonnement, envoyez un message contenant=20
la commande "unsubscribe" a [email protected]
(mailto:[email protected]?Subject=3Dunsubscribe)


No virus found in this incoming message.
Checked by AVG.=20
Version: 7.5.524 / Virus Database: 270.4.1/1521 - Release Date: 26/06/200=
8
11:20
=20

No virus found in this outgoing message.
Checked by AVG.=20
Version: 7.5.524 / Virus Database: 270.4.1/1521 - Release Date: 26/06/200=
8
11:20
=20


-- Binary/unsupported file stripped by Ecartis --
-- Type: application/ms-tnef