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

XML/XSL et SOAP Discussion :

XSL à plusieurs modèles et à plusieurs critères/filtres


Sujet :

XML/XSL et SOAP

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2008
    Messages : 23
    Points : 15
    Points
    15
    Par défaut XSL à plusieurs modèles et à plusieurs critères/filtres
    Bonjour,

    Je début en XML/XSL et je dois dire que ce langage m'ouvre de nombreuses perceptives.

    Je souhaiterais générer sur une page plusieurs modèles selon différents critères.
    Je suis parvenu à afficher mes deux tableaux tests avec les codes ci-dessous.
    Par contre, je souhaiterais rajouter un critère à mon <xsl:apply-templates select="catalogue/domaine[@type='dom1']" /> pour filtrer sur la balise data.

    J'ai tenté sans succès <xsl:apply-templates select="catalogue/domaine[@type='dom1'] and "caatalogue/data[@type='aaa']" />.

    Pourriez-vous, s'il vous plait, m'aider et m'orienter pour cette réalisation.



    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
    <?xml version="1.0"?>
    <?xml-stylesheet type="application/xml" href="bdd.xsl"?>
     
    <catalogue>
     
    <domaine type="dom1">
    <data type="aaa">
    	<profil>profil 1</profil>
    	<dispo>oui</dispo> 
    </data>
    </domaine>
     
    <domaine type="dom1">
    <data type="aaa">
    	<profil>profil 2</profil> 
    	<dispo>non</dispo> 
    </data>
    </domaine>
     
    <domaine type="dom1">
    <data type="bbb">
    	<profil>profil 3</profil> 
    	<dispo>oui</dispo> 
    </data>
    </domaine>
     
    <domaine type="dom2">
    <data type="bbb">
    	<profil>profil 1</profil>
    	<dispo>non</dispo> 
    </data>
    </domaine>
     
    <domaine type="dom2">
    <data type="bbb">
    	<profil>profil 2</profil>
    	<dispo>non</dispo> 
    </data>	
    </domaine>
     
    </catalogue>

    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
    <?xml version="1.0"?> 
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
     
    <xsl:output method="html"/> 
     
    <xsl:template match="/">
    	<html>  
    	<head>  
    		<title>Ma bibliotheque</title>  
    		<style type="text/css">  
    			th {background-color:silver;} 
    			td {border-style:solid; border-width:1px;} 
    		</style>  
    	</head>  
    	<body>  
    		<h2>Bibliotheque</h2>  
    		<table>  
    			<tr>  
    				<th>profil</th>  
    				<th>dispo</th>  
    			</tr>  
    			<xsl:apply-templates select="catalogue/domaine[@type='dom1']" />
    		</table>  
     
    		<br/>
     
     
     
     
    		<table>  
    			<tr>  
    				<th>profil</th>  
    				<th>dispo</th>  
    			</tr>  
    			<xsl:apply-templates select="catalogue/domaine[@type='dom2']" />
    		</table> 
     
     
     
     
     
     
     
    	</body>  
    	</html> 
    </xsl:template> 
     
    <xsl:template match="domaine">
    	<tr>  
    		<td><xsl:value-of select="data/profil"/><i>blablabla</i><xsl:value-of select="data/profil"/><xsl:value-of select="data/profil"/><xsl:value-of select="data/profil"/><xsl:value-of select="data/profil"/></td>  
    		<td><xsl:value-of select="concat(data/profil, ' ', data/dispo)"/></td>  
     
    	</tr>  
    </xsl:template> 
     
     
     
    </xsl:stylesheet>



    Merci,

  2. #2
    Modérateur

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

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Le prédicat doit être écrit comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    catalogue[truc and bidule]
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2008
    Messages : 23
    Points : 15
    Points
    15
    Par défaut
    Cela fonctionne pour remonter tous les résultats mais comment ajouter mes critères "type" à cet appel :

    Quelque chose du genre là ne retournes aucun résultat :

    <xsl:apply-templates select="geocatalogue[domaine[@type='dom1'] and data[@type='aaa']]" />

  4. #4
    Membre émérite Avatar de tsuji
    Inscrit en
    Octobre 2011
    Messages
    1 558
    Détails du profil
    Informations forums :
    Inscription : Octobre 2011
    Messages : 1 558
    Points : 2 736
    Points
    2 736
    Par défaut
    Plutôt comme ça (geocatalogue ou catalogue ?)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:apply-templates select="geocatalogue[domaine[@type='dom1'] and domaine/data[@type='aaa']]" />
    ou bien si vous entendez chercher en imposant conditionnels sur domaine puis le même domaine conditionné en plus sur son enfant data :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:apply-templates select="geocatalogue[domaine[@type='dom1']/data[@type='aaa']]" />

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2008
    Messages : 23
    Points : 15
    Points
    15
    Par défaut
    tsuji, aucun filtre ne semblent passés, toutes les valeurs de mon xml s'affichent et les deux résultats sont identiques ?

  6. #6
    Membre émérite Avatar de tsuji
    Inscrit en
    Octobre 2011
    Messages
    1 558
    Détails du profil
    Informations forums :
    Inscription : Octobre 2011
    Messages : 1 558
    Points : 2 736
    Points
    2 736
    Par défaut
    Faut-il s'entendre ce qu'on parle ?
    Code xml : 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
    <?xml version="1.0"?>
    <?xml-stylesheet type="application/xml" href="bdd.xsl"?>
     <root>
    	<catalogue>
    		<domaine type="dom1">
    			<data type="aaa">
    				<profil>profil 1</profil>
    				<dispo>oui</dispo> 
    			</data>
    		</domaine>
    		<domaine type="dom1">
    			<data type="aaa">
    				<profil>profil 2</profil> 
    				<dispo>non</dispo> 
    			</data>
    		</domaine>
    		<domaine type="dom1">
    			<data type="bbb">
    				<profil>profil 3</profil> 
    				<dispo>oui</dispo> 
    			</data>
    		</domaine>
     		<domaine type="dom2">
    			<data type="bbb">
    				<profil>profil 1</profil>
    				<dispo>non</dispo> 
    			</data>
    		</domaine>
    		<domaine type="dom2">
    			<data type="bbb">
    				<profil>profil 2</profil>
    				<dispo>non</dispo> 
    			</data>	
    		</domaine>
    	</catalogue> 
    	<catalogue>
    		<domaine type="dom1">
    			<data type="aaa">
    				<profil>profil 1</profil>
    				<dispo>oui</dispo> 
    			</data>
    		</domaine>
    		<domaine type="dom1">
    			<data type="aaa">
    				<profil>profil 2</profil> 
    				<dispo>non</dispo> 
    			</data>
    		</domaine>
    	</catalogue>
    </root>

    bdd.xsl
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
    <xsl:template match="/">
    	<xsl:apply-templates select="*" />
    </xsl:template>
    <xsl:template match="root">
    	<xsl:element name="result">
    		<xsl:apply-templates select="catalogue[domaine[@type='dom1']/data[@type='bbb']]" />
    	</xsl:element>
    </xsl:template>
    <xsl:template match="catalogue">
    	<xsl:copy-of select="." />
    </xsl:template>
    </xsl:stylesheet>

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Novembre 2008
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2008
    Messages : 23
    Points : 15
    Points
    15
    Par défaut
    Après avoir beaucoup tatonné, j'ai remplacé l'apply-templates par :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:apply-templates select="/catalogue/domaine[@type='dom2']/data[@type='bbb']" />
    et ça fonctionne nickel.

    Merci pour votre aide,

Discussions similaires

  1. [XL-2007] Comptes de noms uniques plusieurs critères, filtre
    Par AlexandrePLD dans le forum Excel
    Réponses: 1
    Dernier message: 19/09/2013, 03h51
  2. animation de plusieurs modèles en temps réel
    Par shams dans le forum Développement 2D, 3D et Jeux
    Réponses: 4
    Dernier message: 27/03/2007, 11h49
  3. [XSL][FOP] un FO plusieurs fichiers SVG
    Par Sornix dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 24/11/2006, 12h01
  4. [XSLT] <xsl:if> test sur plusieurs condition
    Par oxilab dans le forum XSL/XSLT/XPATH
    Réponses: 8
    Dernier message: 30/06/2006, 20h30
  5. [XSL:~FO][FOP]appeler plusieurs éléments racine.
    Par atoila dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 30/06/2006, 10h53

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