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]un fichier xsl et plusieurs fichiers xml


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Futur Membre du Club
    Inscrit en
    Août 2007
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Août 2007
    Messages : 13
    Points : 8
    Points
    8
    Par défaut [XSLT]un fichier xsl et plusieurs fichiers xml
    Salut tout le monde,
    j'ai à réaliser un projet XML. C une sorte d'un e-service d'achat de produits. Ces produits sont classés par catégorie (informatique, mobilier et papeterie).
    Donc je dispose de trois fichiers xml: inf.xml, mob.xml et pap.xml qui contiennent une liste des produits selon la catégorie. et j'ai un fichier afficherCategorie.xsl.
    Dans le fichier html résultat je dois avoir un combobox qui contient les trois categories, et un bouton "afficher". En choisissant une categorie et en cliquant sur le bouton, les produits de la categorie correspondante doivent etre affichés dans un tableau.
    Donc, on a besoin je pense d'une fonction javascript qui affecte une valeur a une variable xsl selon la categorie choisie. et apres on utilise la variable pour afficher le fichier xml qui correspond a cette categorie.
    En fait, ce n'est qu'une idée pour résoudre le problème mais je ne sais pas comment l'implémenter, surtout comment affecter la valeur de la variable xsl depuis la fonction javascript, et comment utiliser cette variable pour choisir le fichier xml convenable.
    est ce que klk1 peut me guider la dessus car je suis bloquée, et merci d'avance.
    fichier inf.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
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!--!DOCTYPE Classe SYSTEM "classe.dtd"-->
    <?xml-stylesheet type="text/xml"  href="afficherCategorie.xsl"?>
    <!--?xml-stylesheet href="Styles.css" type= "text/css" ?-->
    <Prod_informatiques>
    	<Produit>
    		<Reference>064658</Reference>
    		<Designation>TOSHIBA A100-991</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>8990,21</Prix>
    		<Source>images/064658.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>062401</Reference>
    		<Designation>TOSHIBA P100-340</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>images/11490,21</Prix>
    		<Source>images/062401.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>067027</Reference>
    		<Designation>HP PC Pavilion M7330 Média Center Pentium 4524 3,06 Ghz</Designation>
    		<Disponible>Non</Disponible>
    		<Prix>6000,05</Prix>
    		<Source>images/067027.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>067456</Reference>
    		<Designation>FUJITSU PC ESPRIMO P5700 Celeron 3,4 Ghz</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>5000,05</Prix>
    		<Source>images/067456.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>064734</Reference>
    		<Designation>FUJITSU PC ESPRIMO P5915 Pentium 4 3,4 Ghz</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>6300,05</Prix>
    		<Source>images/064734.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>065813</Reference>
    		<Designation>Ecran plat 19" TFT PHILIPS 190 C7</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>2090,84</Prix>
    		<Source>images/065813.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>066962</Reference>
    		<Designation>Ecran plat 19" NIS DAEWOO</Designation>
    		<Disponible>Non</Disponible>
    		<Prix>1790,84</Prix>
    		<Source>images/066962.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>066961</Reference>
    		<Designation>Ecran plat 17" NIS DAEWOO</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>1490,84</Prix>
    		<Source>images/066961.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>063129</Reference>
    		<Designation>Ecran plat 17" SYM DAEWOO</Designation>
    		<Disponible>Non</Disponible>
    		<Prix>1690,84</Prix>
    		<Source>images/063129.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>064572</Reference>
    		<Designation>Ecran plat LCD 203 B-20" SAMSUNG</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>2490,84</Prix>
    		<Source>images/064572.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>064571</Reference>
    		<Designation>Ecran plat LCD 720 N-17" SAMSUNG</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>1690,84</Prix>
    		<Source>images/064571.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>067535</Reference>
    		<Designation>Scanner Lide 600F CANON</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>1290,13</Prix>
    		<Source>images/067535.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>067124</Reference>
    		<Designation>Scanner ScanJet G4050 HP</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>1690,42</Prix>
    		<Source>images/067124.jpg</Source>
    	</Produit>
    	<Produit>
    		<Reference>064653</Reference>
    		<Designation>Scanner ScanJet N6010 HP</Designation>
    		<Disponible>Oui</Disponible>
    		<Prix>3990,42</Prix>
    		<Source>images/064653.jpg</Source>
    	</Produit>
    </Prod_informatiques>


    fichier afficherCategorie.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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
     
    	<xsl:template match="/">
    		<HTML>
    			<HEAD>
    					<TITLE>Affichage des produits par categorie</TITLE>
    					<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    					<link rel="stylesheet" media="screen" type="text/css" title="Design" href="Styles.css" />
    					<script type="text/javascript" src="Lib.js"></script> 
    			</HEAD>
    			<BODY BGCOLOR="#FFFFFF">
    				<tr bgcolor="#1e90ff">
    					<th align="left"  width="900">
    						<h2>Achat en Ligne</h2>
    					</th>
    				</tr>
    				<br></br>
    				<tr>
    					<th width="100" class="titre">Categorie : </th>
    					<th width="150" align="left">
    						<select name="categorie">
    							<option value="Informatique">Informatique</option>
    							<option value="Mobilier">Mobilier</option>
    							<option value="Papeterie">Papeterie</option>
    						</select>
    					</th>
    				<th><input type="button" value="Afficher" size="200" onclick="afficher(this);"/></th>
    				</tr>
    				<br></br>
    				<br></br>
    				<table bgcolor="#1e90ff">
    				   <tr>
    					   <th class="titre" width="80" align="left">Reference</th>
    					   <th class="titre" width="100" align="left">Source</th>
    					   <th class="titre" width="500" align="left">Designation</th>
    					   <th class="titre" width="150"><img src="images/Panier.gif" alt="Panier" /></th>				   
    				   </tr>
    				</table>
    				<div style="overflow-y:scroll; height:600px; width:860px; border:1px solid black; border-color:#87cefa">
    					<xsl:apply-templates/>
    				</div>
    				<br></br>
    				<br></br>
    				<tr>
    					<th width="800" align="right"><input type="button" value="Ajouter au panier" size="300" onclick="ajouter();"/></th>
    					<th witdh="300" align="right"><input type="button" value="Voir le panier" size="300" onclick="voir();"/></th>
    				</tr>
     
    			</BODY>
    		</HTML>
    	</xsl:template >
    	<xsl:template match="Prod_informatiques/Produit" >
    		<table>
    			<tbody>
    				<tr>
    					<xsl:if test="contains(Disponible,'Oui')">
    						<th class="element" width="80" align="left"><xsl:value-of select="Reference"/></th>
    						<th width="100" align="center">
    							<img>
    								<xsl:attribute name="src">
    									<xsl:value-of select="Source"/>
    								</xsl:attribute>
    							</img>
    						</th>
    						<th class="element" width="500" align="left"><xsl:value-of select="Designation"/></th>
    						<th class="element" width="150"><input type="text" name="quantite"  size="5"/></th>
    					</xsl:if>			
    					<xsl:if test="contains(Disponible,'Non')">
    						<th class="gris" width="80" align="left"><xsl:value-of select="Reference"/></th>							
    						<th width="100" align="center">
    							<img>
    								<xsl:attribute name="src">
    									<xsl:value-of select="Source"/>
    								</xsl:attribute>
    							</img>
    						</th>
    						<th class="gris" width="500" align="left"><xsl:value-of select="Designation"/></th>
    						<th width="150"><input type="text" name="quantite"  size="5" disabled="true"/></th>
    					</xsl:if>
    				</tr>
    			</tbody>
    		</table>			
    	</xsl:template >
    </xsl:stylesheet>

    fichier Lib.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    function afficher(){
    with (document.forms[0].categorie.value){
             document.getElementById('xlslogin')[0].innerHTML='Prod_informatiques/Produit';
    }
    with (document.forms[0].categorie.value){
          document.getElementById('xlslogin')[0].innerHTML='Prod_mobilier/Produit';
    	}
    with (document.forms[0].categorie.value){
          document.getElementById('xlslogin')[0].innerHTML='Prod_papeterie/Produit';
    	}
    }
    En fait j'ai essayé d'utiliser cette fonction pour donner une valeur a une variable xsl mais ça marche pa

  2. #2
    Membre expérimenté
    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
    Points : 1 610
    Points
    1 610
    Par défaut
    Je pense que tu devrais encapsuler ton tableau dans un <form></form> et à la validation déclencher une fonction javascript.
    Celle-ci ouvre une nouvelle page vers un document généré par xslt dont on a valoriser quelques paramètre.
    Regarde là pour voir comment valoriser en javascript les parametre d'une XSLT:
    http://xml.developpez.com/sources/?page=transfo_param

Discussions similaires

  1. [XL-2002] convertir des données d'un fichier excel en plusieurs fichiers XML
    Par 19chacha75 dans le forum Excel
    Réponses: 2
    Dernier message: 06/01/2011, 15h53
  2. Définir plusieurs fichiers xsl
    Par doudounico dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 03/03/2010, 13h37
  3. [XSLT 2.0]Ecriture dans plusieurs fichiers XML
    Par The SorroW dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 21/02/2008, 17h25
  4. [XSLT] Passage de variable entre deux fichiers xsl
    Par kimar dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 18/06/2007, 10h59
  5. [XSL] Plusieurs fichiers xsl
    Par ToxiZz dans le forum Bibliothèques et frameworks
    Réponses: 6
    Dernier message: 10/01/2006, 13h28

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