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 :

Table : changer style row selon condition


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2012
    Messages : 6
    Par défaut Table : changer style row selon condition
    Bonjour,

    Je souhaite changer la couleur de la bordure ainsi que son ombre d'un rang selon une condition à l'aide de "When" mais cela ne marche pas.

    Mon fichier XLM...

    dashboard.xml


    et mon fichier XSL...

    dashboard.xsl

    En fait le rang qui contient les catégories devraient voir la bordure de celui-ci changer de couleur et d'ombre selon l'élément XML "category_id" mais rien n'y fait.

    Merci de votre aide.

    Alain

  2. #2
    Modérateur

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

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 584
    Par défaut
    Je ne vois pas d'élément <category_banner>. Le <xsl:apply-templates select="category_banner" /> ne va donc rien faire.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2012
    Messages : 6
    Par défaut
    Il est pourtant bien présent à la ligne 56 du fichier dashboard.xsl...


    Ci-joint le fichier XSL modifié mais qui ne fonctionne toujours pas...
    Fichiers attachés Fichiers attachés

  4. #4
    Modérateur

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

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 584
    Par défaut
    Euh, voui, mais s'il n'est pas dans le fichier XML ça sert à rien de mettre un template dessus dans le fichier XSLT.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  5. #5
    Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2012
    Messages : 6
    Par défaut
    Juste. Voilà seulement 8 heures que je me dépatouille avec le XML et XSL.

    Pas tout compris , même s'il y a déjà un résultat sur le rendu.

    En fait, je ne vais pas créer de category_banner car aucune valeur à associer à cet élément. Ce qui m'intéresse c'est que mon row où sont affichées les données de category (category_name, category_typeofvalue, category_value et category_unit) change de couleur en fonction de l'élement "category_id" qui varie de 1 à 8.

    J'ai tenté de copier le contenu du template "category_banner au début de mon template category_name mais ce n'est toujours pas ça.

    J'ai lu que XSL-FO pouvait rendre ce genre de service et était plus puissant que XSL pour l'apparence des pages. Y-aurait-il là une (des) solution(s) à mon problème ?

    C'est de plus un option qui risque de m'intéresser pour d'autres pages répétitive et dont certains éléments de celle-ci changent en fonction du contenu des élément du fichier XML.

    Merci de tes réponses.

    Alain
    Fichiers attachés Fichiers attachés

  6. #6
    Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2012
    Messages : 6
    Par défaut @Thelvin : Une piste ?
    Salut Thelvin,

    Désolé de te relancer mais aurais-tu une idée suite aux modifications apportées à mon fichier 2-dashboard.xsl de ma précédente réponse ?

    Alain

  7. #7
    Nouveau candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2013
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Mars 2013
    Messages : 2
    Par défaut
    Bonjour je suis pas sur d'avoir compris ton probleme.
    Mais essaye ça

    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
    	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
    	<xsl:template match="/">
    		<html>
    			<header>
    				<table border="0" style="width: 964px; border-collapse: collapse; margin-left: 15px; margin-top: 10px;">
    					<tr>
    						<td colspan="2" style="width: 75%; font-size: 24px; text-align: left; padding-right: 15px; font-weight: 600;">Tableau de bord</td>
    						<td colspan="3" style="width: auto; font-size: 14px; text-align: right; padding-left: 15px;"><span style="font-weight: 600;"><xsl:value-of select="/dashboard/header/date"/></span></td>
    					</tr>
    					<tr>
    						<td colspan="2" style="width: 75%; font-size: 22px; text-align: left; padding-right: 15px;"><span style="font-weight: 600;"><xsl:value-of select="/dashboard/header/company"/></span></td>
    						<td colspan="3" style="width: auto; font-size: 14px; text-align: right; padding-left: 15px;"><span style="font-weight: 600;"><xsl:value-of select="/dashboard/header/time"/></span></td>
    					</tr>
    					<tr>
    						<td colspan="2" style="width: 75%; font-size: 22px; text-align: left; padding-right: 15px;"><span style="font-weight: 600;"><xsl:value-of select="/dashboard/header/name"/></span></td>
    						<td colspan="3" style="width: auto; font-size: 14px; text-align: right; padding-left: 15px;"><span style="font-weight: 600;"><xsl:value-of select="/dashboard/header/from"/></span></td>
    					</tr>
    				</table>
    			</header>
    			<body style="background-image: none">
    				<table border="0" style="width: 964px; border-collapse: collapse;">
    					<xsl:apply-templates select="/dashboard/category" />
    				</table>
    				<br />
    			</body>
    			<footer>
    				<table border="0" style="width: 964px; border-collapse: collapse; margin-left: 10px; margin-top: 10px;">
    					<tr>
    						<td colspan="5" style="width: auto; font-size: 10px; padding-left: 15px;">Energy Logger est un service proposé par la société 3iDS Sarl (Genève - Suisse)</td>
    					</tr>
    				</table>				
    			</footer>
    		</html>
    	</xsl:template>
     
    	<xsl:template match="category">			
    		<table border="0" style="width: 964px; border-collapse: collapse; margin-left: 10px; margin-top: 20px;">
    			<tr style="background-color: white; border-width: 1px; border-color: black; box-shadow: 0px 0px 4px black;">
    				<!--<xsl:apply-templates select="category_banner" />-->
    				<xsl:apply-templates select="." mode="category_banner" />
    				<xsl:apply-templates select="category_name" />
    				<xsl:apply-templates select="category_typeofvalue" />
    				<xsl:apply-templates select="category_value" />
    				<xsl:apply-templates select="category_unit" />
    			</tr>
    			<tr>
    				<td colspan="4">
    					<xsl:apply-templates select="datatype" />
    				</td>
    			</tr>
    		</table>
    	</xsl:template>
     
    	<xsl:template match="category" mode="category_banner">
    		<xsl:choose>
    			<xsl:when test="category_id = '1'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #FF0000;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '2'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #FF00FF;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '3'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #009900;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '4'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #00FF00;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '5'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #6CD7FF;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '6'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #FF8F20;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '7'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #011DA0;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '8'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #925710;</xsl:attribute>
    			</xsl:when>
    			<xsl:otherwise>
    				<xsl:attribute name="style">border-color: black; box-shadow: 0px 0px 4px black;</xsl:attribute>
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
     
    	<xsl:template match="category_name">
    		<xsl:choose>
    			<xsl:when test="category_id = '1'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #FF0000;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '2'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #FF00FF;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '3'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #009900;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '4'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #00FF00;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '5'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #6CD7FF;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '6'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #FF8F20;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '7'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #011DA0;</xsl:attribute>
    			</xsl:when>
    			<xsl:when test="category_id = '8'">
    				<xsl:attribute name="style">border-color: #92CE05; box-shadow: 0px 0px 4px #925710;</xsl:attribute>
    			</xsl:when>
    			<xsl:otherwise>
    				<xsl:attribute name="style">border-color: black; box-shadow: 0px 0px 4px black;</xsl:attribute>
    			</xsl:otherwise>
    		</xsl:choose>
    		<td style="width: 395px;  padding-left: 5px; padding-right: 0px; text-align:  left; font-size: 22px; font-weight: 600; "><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="category_typeofvalue">
    		<td style="width: 300px;  padding-left: 0px; padding-right: 20px; text-align:  right; font-size: 16px; font-weight: 600; "><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="category_value">
    		<td style="width: 100px;  padding-left:  0px; padding-right:  0px; text-align: center; font-size: 28px; font-weight: 600; background-color: white;"><xsl:value-of select="."/></td>
    		<xsl:apply-templates select="category_color" />
    	</xsl:template>
     
    	<xsl:template match="category_color">
    		<xsl:attribute name="style"><xsl:value-of select="."/></xsl:attribute>
    	</xsl:template>
     
    	<xsl:template match="category_unit">
    		<td style="width: 164px;  padding-left:  5px; padding-right: 0px; text-align: center; font-size: 20px; font-weight: 600;"><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="datatype">
    		<table border="0" style="width: 963px; border-collapse: collapse; margin-top: 10px;">
    			<tr>
    				<xsl:apply-templates select="datatype_name" />
    				<xsl:apply-templates select="datatype_typeofvalue" />
    				<xsl:apply-templates select="datatype_value" />
    				<xsl:apply-templates select="datatype_unit" />
    			</tr>
    		</table>
    		<tr>
    			<td>
    				<xsl:apply-templates select="counter" />
    			</td>
    		</tr>
    	</xsl:template>
     
    	<xsl:template match="datatype_name">
    		<td style="width: 375px; padding-left: 25px; padding-right:  0px; text-align: left; font-size: 18px; font-weight: 600;"><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="datatype_typeofvalue">
    		<td style="width: 295px;  padding-left: 5px; padding-right: 20px; text-align:  right; font-size: 16px; font-weight: 200; "></td>
    	</xsl:template>
     
    	<xsl:template match="datatype_value">
    		<td style="width: 100px; padding-left: 0px; padding-right: 0px; text-align: center; font-size: 22px; font-weight: 600; background-color: border-width: 1px; border-color: black; box-shadow: 0px 0px 4px #808080;"><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="datatype_unit">
    		<td style="width: 158px;  padding-left:  6px; padding-right:  0px; text-align: center; font-size: 20px; font-weight: 600; color: #808080"><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="counter">
    		<table border="0" style="width: 964px; border-collapse: collapse; margin-top: 10px;">
    			<tr>
    				<td style="width: 120px; padding-left: 45px; padding-right: 0px; text-align: left; font-size: 14px; font-weight: 500;">Compteur / Sonde</td>
    				<xsl:apply-templates select="counter_name" />
    				<xsl:apply-templates select="counter_value" />
    				<xsl:apply-templates select="counter_unit" />
    			</tr>
    		</table>
    	</xsl:template>
     
    	<xsl:template match="counter_name">
    		<td style="width: 503px; padding-left: 45px; padding-right: 20px; text-align: right; font-size: 14px; font-weight: 500;"><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="counter_value">
    		<td style="width: 100px; padding-left:  5px; padding-right:  0px; text-align: center; font-size: 18px; font-weight: 600; background-color: white; color: #111; border-width: 1px; border-color: black; box-shadow: 0px 0px 4px #808080;"><xsl:value-of select="."/></td>
    	</xsl:template>
     
    	<xsl:template match="counter_unit">
    		<td style="width: 166px;  padding-left:  5px; padding-right:  0px; text-align: center; font-size: 20px; font-weight: 600; "></td>
    	</xsl:template>
     
    </xsl:stylesheet>

  8. #8
    Nouveau candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2013
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Mars 2013
    Messages : 2
    Par défaut
    regarde ça.
    si c'est pas ça que tu veux explique mieux ou donne le resultat souhaité.
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. [XL-2003] Changer la couleur de fond d'une cellule selon condition
    Par iIncoming dans le forum Excel
    Réponses: 6
    Dernier message: 03/03/2013, 09h33
  2. [XL-2003] pivot table selon conditions
    Par hantran dans le forum Macros et VBA Excel
    Réponses: 0
    Dernier message: 09/06/2010, 16h10
  3. Transfert vers une table selon condition
    Par Monsieur Peck dans le forum Requêtes et SQL.
    Réponses: 8
    Dernier message: 13/06/2006, 13h34
  4. [VB.NET] Changer de classe selon condition
    Par daner06 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 24/10/2004, 10h04

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