Re: Traitement selon sous-balise

Eric van der Vlist <[email protected]> Thu, 26 Jun 2008 23:33:32 +0200
Newsgroups gmane.text.xml.french.tech
Organization Dyomedea (http://dyomedea.com)
Message-ID <1214516012.3412.25.camel@localhost>
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
             test=3D"contains(translate(name(current()),$translate-from,$=
translate-to),'auteur') and Emph">

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

          </xsl:when>
          <xsl:when

            test=3D"contains(translate(name(current()),$translate-from,$t=
ranslate-to),'auteur')">
            <!-- 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
             test=3D"contains(translate(name(current()),$translate-from,$=
translate-to),'auteur')">

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

          </xsl:when>
   ...

...

</xsl:template>=20


on pourrait avoir :


=EF=BB=BF         <xsl:template
             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
             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-----