IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

XSL/XSLT/XPATH XML Discussion :

Probleme de selection d'image [XSLT 1.0]


Sujet :

XSL/XSLT/XPATH XML

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Homme Profil pro
    Webmaster
    Inscrit en
    Février 2013
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Webmaster
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2013
    Messages : 2
    Par défaut Probleme de selection d'image
    Bonjour à Tous,
    Je viens de m'inscrire car je cherche quelques réponse en codage XSL.

    Voilà, je débute en XSL et j'ai un souci d'affiche d'image.
    C'est des annonces de voitures et j'aimerais n'afficher que celle qui comporte que des images et uniquement celle commençant par _PHOTO/_0

    Pourriez vous me donner un ptit coup de main sur ce problème.
    Merci à vous.

    Mon code XSL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="xhtml">
      <xsl:output method="xml" encoding="iso-8859-1" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" />
     
    <xsl:template match="/module/content/_result/_data">
      <xsl:apply-templates select="*[_PRICE &gt; 4999 and _PRICE &lt; 20001]/_BRAND"/>
    </xsl:template>
     
    <xsl:template match="_BRAND">
        <xsl:variable name="lien">
          <xsl:text>http://logp.xiti.com/go.ad?xts=</xsl:text>
          <xsl:text>##f##</xsl:text>
          <!-- xitisiteid -->
          <xsl:text>&atc=PUB-[D_</xsl:text>
          <xsl:text>##a##</xsl:text>
          <!-- campagneid -->
          <xsl:text>]-[</xsl:text>
          <xsl:text>##d##</xsl:text>
          <!-- templateid -->
          <xsl:text>]-[</xsl:text>
          <xsl:text>##b##</xsl:text>
          <!-- variantid -->
          <xsl:text>]-[</xsl:text>
          <xsl:text>##e##</xsl:text>
          <!-- encartid -->
          <xsl:text>]---[D_</xsl:text>
          <xsl:text>##c##</xsl:text>
          <!-- partenaireid -->
          <xsl:text>]-&type=AT&url=</xsl:text>
          <xsl:value-of select="../_URL"/>
        </xsl:variable>
     
        <xsl:if test="position() &lt; 2">
          <div class="bloc_content">
            <div class="bloc_partenaire_1img">
                  <a target="_blank">
                    <xsl:attribute name="href"><xsl:value-of select="$lien" /></xsl:attribute>
                      <img width="300">
                        <xsl:attribute name="src"><xsl:value-of select="../_PHOTO/_0"/></xsl:attribute>
                        <xsl:attribute name="alt"><xsl:value-of select="../_MODEL"/></xsl:attribute>
                      </img>
                  </a>
                  <p class="button button_dark">
                    <a class="simple_arrow" target="_blank">
                      <xsl:attribute name="href"><xsl:value-of select="$lien" /></xsl:attribute>
                      <xsl:text>Voir l'annonce</xsl:text>
                    </a>
                  </p>
                  <div class="item_title">
                    <a target="_blank">
                      <xsl:attribute name="href"><xsl:value-of select="$lien" /></xsl:attribute>
                      <xsl:value-of select="../_BRAND"/>*<xsl:value-of select="../_MODEL"/>
                    </a>
                  </div>
                  <p>Prix : <xsl:value-of select="../_PRICE"/></p>
                  <p>Département : <xsl:value-of select="../_VISITPLACE"/></p>
              </div>
            </div>
        </xsl:if>
      </xsl:template>
     
    </xsl:stylesheet>


    et mon code XML :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <module id="2933">
    	<content appearance="" appearance_slug="">
    		<_result>
    			<_erreur>
    </_erreur>
    			<_data>
    				<_0>
    					<_BRAND>VOLKSWAGEN</_BRAND>
    					<_MODEL>GOLF</_MODEL>
    					<_VERSION>VI 20 TDI 110 FAP CR CARAT 5P</_VERSION>
    					<_PRICE>13900</_PRICE>
    					<_VISITPLACE>02</_VISITPLACE>
    					<_URL>http://www.lacentrale.fr/auto-occasion-annonce-19433535.html</_URL>
    					<_PHOTO/>
    				</_0>
    				<_1>
    					<_BRAND>MAZDA</_BRAND>
    					<_MODEL>5</_MODEL>
    					<_VERSION>20 MZR-CD 110 ELEGANCE 7PL</_VERSION>
    					<_PRICE>9390</_PRICE>
    					<_VISITPLACE>28</_VISITPLACE>
    					<_URL>http://www.lacentrale.fr/auto-occasion-annonce-19384997.html</_URL>
    					<_PHOTO>
    						<_0>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508.jpg</_0>
    						<_1>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_1.jpg</_1>
    						<_2>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_2.jpg</_2>
    						<_3>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_3.jpg</_3>
    						<_4>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_4.jpg</_4>
    						<_5>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_5.jpg</_5>
    						<_6>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_6.jpg</_6>
    						<_7>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_7.jpg</_7>
    						<_8>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_8.jpg</_8>
    						<_9>http://photo.lacentrale.fr/photo/lc/E1/06/51/E10651508_9.jpg</_9>
    					</_PHOTO>
    				</_1>
    				<_2>
    					<_BRAND>PEUGEOT</_BRAND>
    					<_MODEL>107</_MODEL>
    					<_VERSION>2 10 TRENDY 5P</_VERSION>
    					<_PRICE>6990</_PRICE>
    					<_VISITPLACE>14</_VISITPLACE>
    					<_URL>http://www.lacentrale.fr/auto-occasion-annonce-19425713.html</_URL>
    					<_PHOTO>
    						<_0>http://photo.lacentrale.fr/photo/lc/E1/06/79/E10679125.jpg</_0>
    						<_1>http://photo.lacentrale.fr/photo/lc/E1/06/79/E10679125_1.jpg</_1>
    						<_2>http://photo.lacentrale.fr/photo/lc/E1/06/79/E10679125_2.jpg</_2>
    						<_3>http://photo.lacentrale.fr/photo/lc/E1/06/79/E10679125_3.jpg</_3>
    						<_4>http://photo.lacentrale.fr/photo/lc/E1/06/79/E10679125_4.jpg</_4>
    					</_PHOTO>
    				</_2>
    				<_3>
    					<_BRAND>AUDI</_BRAND>
    					<_MODEL>S6</_MODEL>
    					<_VERSION>III 52 V10 435 QUATTRO TIPTRONIC</_VERSION>
    					<_PRICE>33490</_PRICE>
    					<_VISITPLACE>77</_VISITPLACE>
    					<_URL>http://www.lacentrale.fr/auto-occasion-annonce-18864939.html</_URL>
    					<_PHOTO>
    						<_0>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671.jpg</_0>
    						<_1>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_1.jpg</_1>
    						<_2>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_2.jpg</_2>
    						<_3>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_3.jpg</_3>
    						<_4>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_4.jpg</_4>
    						<_5>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_5.jpg</_5>
    						<_6>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_6.jpg</_6>
    						<_7>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_7.jpg</_7>
    						<_8>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_8.jpg</_8>
    						<_9>http://photo.lacentrale.fr/photo/lc/W1/02/93/W10293671_9.jpg</_9>
    					</_PHOTO>
    				</_3>
    			</_data>
    		</_result>
    	</content>
    </module>

  2. #2
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 582
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 582
    Par défaut
    Eh bien, il faut tester l'existence de _PHOTO/_0, par exemple en ajoutant un prédicat :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:apply-templates select="*[_PRICE &gt; 4999 and _PRICE &lt; 20001 and _PHOTO/_0]/_BRAND"/>
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [CR.NET] Probleme d'affichage d'image
    Par ahervieux dans le forum SAP Crystal Reports
    Réponses: 3
    Dernier message: 25/06/2005, 14h06
  2. Probleme avec Select Case
    Par GeffD dans le forum MS SQL Server
    Réponses: 7
    Dernier message: 07/03/2005, 15h28
  3. probleme redimensionnement d'une image
    Par meteor4 dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 29/11/2004, 13h58
  4. Mkisofs - problème pour créer une image
    Par tomnie dans le forum Applications et environnements graphiques
    Réponses: 4
    Dernier message: 04/08/2004, 11h44
  5. [TP][MULTI-PROBLEME]Comment afficher des images pcx
    Par mikoeur dans le forum Turbo Pascal
    Réponses: 7
    Dernier message: 24/10/2002, 13h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo