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 :

[XSLT] comment afficher toutes les données d'un fichier xml ?


Sujet :

XSL/XSLT/XPATH XML

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 39
    Par défaut [XSLT] comment afficher toutes les données d'un fichier xml ?
    bonjour
    il y a t il un fichier xsl standard qui permet tous simplement et bettement d'afficher toutes les données d'un fichier xml ?
    merci

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    1 466
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 1 466
    Par défaut
    Un fichier xsl définit une transformation d'un format xml en entrée vers une sortie ASCII quelconque et non un affichage.
    Quand tu dis "afficher", c'est afficher par qui/quoi/quel logiciel.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 39
    Par défaut
    ok alors je voulais dire transformation

  4. #4
    Membre Expert
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    1 466
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 1 466
    Par défaut
    Et bien soit plus explicite sur ton format de sortie.

  5. #5
    Membre émérite
    Profil pro
    Responsable Dev
    Inscrit en
    Décembre 2003
    Messages
    788
    Détails du profil
    Informations personnelles :
    Localisation : France, Vendée (Pays de la Loire)

    Informations professionnelles :
    Activité : Responsable Dev

    Informations forums :
    Inscription : Décembre 2003
    Messages : 788
    Par défaut
    Oui pour répondre à ta question il faudrait savoir dans quoi tu veux afficher ton xml

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    39
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 39
    Par défaut
    je veux juste afficher toute mes noeuds un aprés l'autre et sans aucun format comme début mais si tu veut quelque chose de plus compliquer tu peux voir le format du fichier pdf et aussi mon fichier xml ici :
    http://www.developpez.net/forums/sho...51#post2233051

    car en fait les noeuds dans mon fichier xml sont dynamiques et portent tous le même nom
    mais vraiment j'ai pas pus même les afficher tous simplement !!
    je te previens je suis débutant

  7. #7
    Rédacteur

    Avatar de Erwy
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2003
    Messages
    4 967
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2003
    Messages : 4 967
    Par défaut
    En HTML, un affichage type IE/mozilla
    Il y a une version simple qui ne prend pas les namespace en compte dans les codes sources
    http://xml.developpez.com/sources/?page=HTML#VII_html
    Ce code prend en compte les namespace et sera ajouté à la procahine modif des codes sources
    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
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
     
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\AMOUREUX\Mes documents\xmlsource\HTML.xslt"?>
    <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:variable name="tab" select="' '"/>
    	<xsl:template match="/">
    		<html>
    			<head>
    				<title>presentation xslt</title>
    				<style type="text/css">
    .PI
    {
    color:green;
    }
    .comment
    {
    color:gray;
    }
    .element
    {
    color:brown;
    }
    .attribut
    {
    color:red;
    }
    .text
    {
    color:black;
    }
    .signe
    {
    color:blue;
    }
    .marge
    {
    margin-left:15px;
    }
    </style>
    			</head>
    			<body>
    				<span class="PI">&lt;?xml version="1.0" ?&gt;</span>
    				<xsl:apply-templates select="node()">
    					<xsl:with-param name="ns" select="//namespace::*[name()!='xml']"/>
    				</xsl:apply-templates>
    			</body>
    		</html>
    	</xsl:template>
    	<xsl:template match="*[not(node())]">
    		<xsl:param name="ns"/>
    		<div class="marge">
    			<span class="signe">&lt;</span>
    			<span class="element">
    				<xsl:value-of select="name()"/>
    			</span>
    			<xsl:apply-templates select="@*"/>
    			<xsl:choose>
    				<xsl:when test="$ns">
    					<xsl:choose>
    						<xsl:when test="$ns[.=namespace-uri(current()) and name()=substring-before(name(current()),':')]">
    							<xsl:variable name="nsTamp" select="$ns[.!=namespace-uri(current()) or name()!=substring-before(name(current()),':')]"/>
    							<xsl:choose>
    								<xsl:when test="local-name()=name()  ">
    									<span class="attribut">
    										<xsl:value-of select="concat($tab,'xmlns')"/>
    									</span>
    									<span class="signe">="</span>
    									<span class="text">
    										<xsl:value-of select="namespace-uri()"/>
    									</span>
    									<span class="signe">"</span>
    								</xsl:when>
    								<xsl:when test="local-name()!=name() ">
    									<span class="attribut">
    										<xsl:value-of select="concat($tab,'xmlns:',substring-before(name(),':'))"/>
    									</span>
    									<span class="signe">="</span>
    									<span class="text">
    										<xsl:value-of select="namespace-uri()"/>
    									</span>
    									<span class="signe">"</span>
    								</xsl:when>
    							</xsl:choose>
    							<xsl:call-template name="nsAttrib">
    								<xsl:with-param name="Lattrib" select="@*[namespace-uri()]"/>
    								<xsl:with-param name="Lns" select="$nsTamp"/>
    								<xsl:with-param name="finTag" select="'/'"/>
    							</xsl:call-template>
    						</xsl:when>
    						<xsl:otherwise>
    							<xsl:call-template name="nsAttrib">
    								<xsl:with-param name="Lattrib" select="@*[namespace-uri()]"/>
    								<xsl:with-param name="Lns" select="$ns"/>
    								<xsl:with-param name="finTag" select="'/'"/>
    							</xsl:call-template>
    						</xsl:otherwise>
    					</xsl:choose>
    				</xsl:when>
    				<xsl:otherwise>
    					<span class="signe">/&gt;</span>
    				</xsl:otherwise>
    			</xsl:choose>
    		</div>
    	</xsl:template>
    	<xsl:template match="*[node()]">
    		<xsl:param name="ns"/>
    		<div class="marge">
    			<span class="signe">&lt;</span>
    			<span class="element">
    				<xsl:value-of select="name()"/>
    			</span>
    			<xsl:apply-templates select="@*"/>
    			<xsl:choose>
    				<xsl:when test="$ns">
    					<xsl:choose>
    						<xsl:when test="$ns[.=namespace-uri(current()) and name()=substring-before(name(current()),':')]">
    							<xsl:variable name="nsTamp" select="$ns[.!=namespace-uri(current()) or name()!=substring-before(name(current()),':')]"/>
    							<xsl:choose>
    								<xsl:when test="local-name()=name()  ">
    									<span class="attribut">
    										<xsl:value-of select="concat($tab,'xmlns')"/>
    									</span>
    									<span class="signe">="</span>
    									<span class="text">
    										<xsl:value-of select="namespace-uri()"/>
    									</span>
    									<span class="signe">"</span>
    								</xsl:when>
    								<xsl:when test="local-name()!=name() ">
    									<span class="attribut">
    										<xsl:value-of select="concat($tab,'xmlns:',substring-before(name(),':'))"/>
    									</span>
    									<span class="signe">="</span>
    									<span class="text">
    										<xsl:value-of select="namespace-uri()"/>
    									</span>
    									<span class="signe">"</span>
    								</xsl:when>
    							</xsl:choose>
    							<xsl:call-template name="nsAttrib">
    								<xsl:with-param name="Lattrib" select="@*[namespace-uri()]"/>
    								<xsl:with-param name="Lns" select="$nsTamp"/>
    							</xsl:call-template>
    						</xsl:when>
    						<xsl:otherwise>
    							<xsl:call-template name="nsAttrib">
    								<xsl:with-param name="Lattrib" select="@*[namespace-uri()]"/>
    								<xsl:with-param name="Lns" select="$ns"/>
    							</xsl:call-template>
    						</xsl:otherwise>
    					</xsl:choose>
    				</xsl:when>
    				<xsl:otherwise>
    					<span class="signe">&gt;</span>
    					<xsl:apply-templates select="node()"/>
    				</xsl:otherwise>
    			</xsl:choose>
    			<span class="signe">&lt;/</span>
    			<span class="element">
    				<xsl:value-of select="name()"/>
    			</span>
    			<span class="signe">&gt;</span>
    		</div>
    	</xsl:template>
    	<xsl:template match="text()">
    		<span class="text">
    			<xsl:value-of select="."/>
    		</span>
    	</xsl:template>
    	<xsl:template match="comment()">
    		<span class="comment">&lt;!--<xsl:value-of select="."/>--&gt;</span>
    	</xsl:template>
    	<xsl:template match="@*">
    		<span class="attribut">
    			<xsl:value-of select="concat($tab,name())"/>
    		</span>
    		<span class="signe">="</span>
    		<span class="text">
    			<xsl:value-of select="."/>
    		</span>
    		<span class="signe">"</span>
    	</xsl:template>
    	<xsl:template match="processing-instruction()">
    		<div class="marge">
    			<span class="PI">&lt;?<xsl:value-of select="concat(name(),$tab,.)"/>?&gt;</span>
    		</div>
    	</xsl:template>
    	<xsl:template name="nsAttrib">
    		<xsl:param name="Lattrib"/>
    		<xsl:param name="Lns"/>
    		<xsl:param name="finTag" select="''"/>
    		<xsl:choose>
    			<xsl:when test="$Lattrib and $Lns">
    				<xsl:choose>
    					<xsl:when test="$Lns[.=namespace-uri($Lattrib[1]) and name()=substring-before(name($Lattrib[1]),':')]">
    						<span class="attribut">
    							<xsl:value-of select="concat($tab,'xmlns:',substring-before(name($Lattrib[1]),':'))"/>
    						</span>
    						<span class="signe">="</span>
    						<span class="text">
    							<xsl:value-of select="namespace-uri($Lattrib[1])"/>
    						</span>
    						<span class="signe">"</span>
    						<xsl:call-template name="nsAttrib">
    							<xsl:with-param name="Lattrib" select="$Lattrib[substring-before(name($Lattrib[1]),':')!=substring-before(name(),':')  or namespace-uri()!=namespace-uri($Lattrib[1]) ]"/>
    							<xsl:with-param name="Lns" select="$Lns[.!=namespace-uri($Lattrib[1]) or name()!=substring-before(name($Lattrib[1]),':')]"/>
    							<xsl:with-param name="finTag" select="$finTag"/>
    						</xsl:call-template>
    					</xsl:when>
    					<xsl:otherwise>
    						<xsl:call-template name="nsAttrib">
    							<xsl:with-param name="Lattrib" select="$Lattrib[substring-before(name($Lattrib[1]),':')!=substring-before(name(),':')  or namespace-uri()!=namespace-uri($Lattrib[1]) ]"/>
    							<xsl:with-param name="Lns" select="$Lns"/>
    							<xsl:with-param name="finTag" select="$finTag"/>
    						</xsl:call-template>
    					</xsl:otherwise>
    				</xsl:choose>
    			</xsl:when>
    			<xsl:otherwise>
    				<span class="signe">
    					<xsl:value-of select="$finTag"/>&gt;</span>
    				<xsl:apply-templates select="node()">
    					<xsl:with-param name="ns" select="$Lns"/>
    				</xsl:apply-templates>
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
    </xsl:stylesheet>

Discussions similaires

  1. Comment afficher toute les pages du rapport ?
    Par savoir dans le forum Rave
    Réponses: 0
    Dernier message: 14/10/2008, 09h18
  2. Afficher toutes les données d'une liste déroulante
    Par erwand dans le forum InfoPath
    Réponses: 1
    Dernier message: 05/09/2008, 10h42
  3. Comment afficher toutes les courbes avec contourf ?
    Par developpeur82 dans le forum MATLAB
    Réponses: 2
    Dernier message: 02/04/2007, 11h14
  4. [MySQL] Afficher toutes les données d'un champ dans une liste déroulante
    Par Touareg dans le forum PHP & Base de données
    Réponses: 10
    Dernier message: 19/03/2007, 12h42
  5. [XSLT] comment afficher tous les noms de balises
    Par stanilas dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 12/11/2005, 22h24

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