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 :

[XSL] récursivité ... impossible ????


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut [XSL] récursivité ... impossible ????
    ------------------------------------MON FICHIER 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
    <FMPDSORESULT>
      <ROW>
         <TLS_S_NomTache>Tache1</TLS_S_NomTache>
         <TLS_S_Scenario>Scenario 1.1</TLS_S_Scenario>
         <TLS_TLA_NomTLA1>lot1.1</TLS_TLA_NomTLA1>
         <TLS_TLA_NomTLA2>lot1.2</TLS_TLA_NomTLA2>
         <TLS_TLA_NomTLA3>lot1.3</TLS_TLA_NomTLA3>
      </ROW>
      <ROW>
         <TLS_S_NomTache>Tache1</TLS_S_NomTache>
         <TLS_S_Scenario>Scenario 1.1</TLS_S_Scenario>
         <TLS_TLA_NomTLA1>lot2</TLS_TLA_NomTLA1>
      </ROW>
      <ROW>
         <TLS_S_NomTache>Tache2</TLS_S_NomTache>
         <TLS_S_Scenario>Scenario 2</TLS_S_Scenario>
         <TLS_TLA_NomTLA1>lot3</TLS_TLA_NomTLA1>
      </ROW>
      ...   
    </FMPDSORESULT>
    ------------------------------------MON FICHIER XML de sortie
    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
    <map>
      <node TEXT="hypertim">
      <edge WIDTH="1" STYLE="bezier"/>
        <node TEXT="tache1" POSITION="right">
        <edge WIDTH="1" STYLE="bezier"/>
          <node TEXT="scenario1.1">
          <edge WIDTH="1" STYLE="bezier"/>
            <node TEXT="type de lot">
            <edge WIDTH="1" STYLE="bezier"/>
              <node TEXT="lot1.1"><edge WIDTH="1" STYLE="bezier"/></node>
              <node TEXT="lot1.2"><edge WIDTH="1" STYLE="bezier"/></node>
              <node TEXT="lot1.3"> <edge WIDTH="1" STYLE="bezier"/></node>
            </node>
            <node TEXT="lot2" /> 
          </node>
          <node TEXT="scenario1.2" /> 
        </node>
        <node TEXT="tache2" POSITION="right">
        <edge WIDTH="1" STYLE="bezier"/>
          <node TEXT="scenario2">
          <edge WIDTH="1" STYLE="bezier"/>
            <node TEXT="lot3"><edge WIDTH="1" STYLE="bezier"/></node>
          </node>
        </node>
      </node>
    </map>
    ------------------------------------MON 2eme FICHIER 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
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fmp="http://www.filemaker.com/fmpdsoresult" exclude-result-prefixes="fmp">
    <xsl:output method="xml" encoding="iso-8859-1"/>
     
    <xsl:template match="fmp:FMPDSORESULT"> 
     <xsl:element name="map">
        <xsl:apply-templates select="*"/>
     </xsl:element>
    </xsl:template>
     
    <xsl:template match="fmp:ROW">
      <xsl:element name="node">
        <xsl:apply-templates select="*"/>
       </xsl:element>
    </xsl:template>
     
    <xsl:template match="*">
      <xsl:attribute name="TEXT"><xsl:value-of select="fmp:TLS_S_NomTache"/></xsl:attribute>
      <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
      <xsl:element name="edge">
         <xsl:attribute name="width"> <xsl:text>1</xsl:text></xsl:attribute>
         <xsl:attribute name="STYLE"><xsl:text>bezier</xsl:text></xsl:attribute>
      </xsl:element>
    </xsl:template>
    </xsl:stylesheet>

    Ce fichier XSL ne convient pas du tout, mais c'est un peu pres tout ce que j'ai pu trouvé.
    Pourriez-vous m'aider à trouver la solution qui me parait bien compliqué.

  2. #2
    Expert éminent
    Avatar de GrandFather
    Inscrit en
    Mai 2004
    Messages
    4 587
    Détails du profil
    Informations personnelles :
    Âge : 54

    Informations forums :
    Inscription : Mai 2004
    Messages : 4 587
    Points : 7 103
    Points
    7 103
    Par défaut
    Bonjour,

    il va falloir te fendre d'une description un peu plus précise de ton problème, parce qu'on n'a pas trop envie de deviner. D'autant qu'il y a des données dans le XML de sortie qu'on ne trouve ni dans le XML d'entrée, ni dans la feuille de style... Précise les règles de production de ton XML de sortie, et dis-nous l'endroit où tu bloques.
    (indication: c'est très urgent)
    Indication inutile, nous n'avons aucune obligation de moyens ni de résultats...
    FAQ XML
    ------------
    « Le moyen le plus sûr de cacher aux autres les limites de son savoir est de ne jamais les dépasser »
    Giacomo Leopardi

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut
    Tout d'abord désolé pour l'indication (supprimé maintenant), et merci pour ce forum qui m'a souvent dépanné.

    J'ai essayé de clarifier la situation. Mais est-ce possible ?
    Merci
    ----------

    - FMPDORESULT doit être transformer en map

    - Dans chaque ROW, on trouve un tache, un scenario, et des lots.
    On remarque que parfois les ROWs ont la même tache, et le même scénario.

    - Le but étant de créer une arborescence dont la structure est la suivante :
    Arbo (1er noeud, constant) --> Tache --> Scénario --> type de lots (qd on a plus d'un lot) --> lots

    On voit qu'il ne faut pas de doublons, c-a-d que l'on ne trouve pas 2X le même nom de tâche.
    Ici, il faudrait non pas :

    ======================
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Tache1 --> Scénario 1.1 --> type de lots --> lot1.1
                                                 lot1.2                      
                                                 lot1.3
     
    Tache1 --> Scénario 1.1 --> lot2
     
    Tache2 --> Scénario 2.1 --> lot3
    mais==================
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    -Arbo --> Tache1 --> Scénario 1.1 --> type de lots --> lot1.1
         |                                            |    lot1.2                      
         |                                            |    lot1.3
         |                                            |
         |                                             --> lot2
         |
          --> Tache2 --> Scénario 2.1 --> lot3
    ======================

    Le fichier de sortie est structuré vraiment ainsi :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <map>
        <node TEXT="Tache">
        <edge WIDTH="1" STYLE="bezier"/>
           <node>
           <edge WIDTH="1" STYLE="bezier"/>
              ...
           </node>
        <node>
    </map>

  4. #4
    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 : 47
    Localisation : France

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 4 967
    Points : 10 927
    Points
    10 927
    Par défaut
    soit un fichier xml du type

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    <D>
    <r><a>1</a><b>a</b></r>
    <r><a>1</a><b>b</b></r>
    <r><a>2</a><b>a</b></r>
    <r><a>3</a><b>b</b></r>
    </D>
    la sortie
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <racine>
    	<r1>
    		<a>1</a>
    		<r2>
    			<b>a</b>
    			<b>b</b>
    		</r2>
    	</r1>
    	<r1>
    		<a>2</a>
    		<r2>
    			<b>a</b>
    		</r2>
    	</r1>
    	<r1>
    		<a>3</a>
    		<r2>
    			<b>b</b>
    		</r2>
    	</r1>
    </racine>
    le 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
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    	<xsl:key match="a" name="cle" use="."/>
    	<xsl:template match="/">
    		<racine>
    			<xsl:apply-templates select="//a[generate-id(.)=generate-id(key('cle',.)[1])]"/>
    		</racine>
    	</xsl:template>
    	<xsl:template match="a">
    		<r1>
    			<xsl:copy-of select="."/>
    			<r2>
    				<xsl:apply-templates select="//b[../a=current()]"/>
    			</r2>
    		</r1>
    	</xsl:template>
    	<xsl:template match="b">
    		<xsl:copy-of select="."/>
    	</xsl:template>
    </xsl:stylesheet>
    Ces deux parties permettent de supprimer les doublons, cela est expliqué plus en detail ailleurs dans le forum
    <xsl:key match="a" name="cle" use="."/>

    <xsl:apply-templates select="//a[generate-id(.)=generate-id(key('cle',.)[1])]"/>

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut
    Merci bcp Erwy, j'ai réussi partiellement à faire la transformation. Malheureusement, je récupère tous les doublons avec <r2> (fmp:TLS_S_NomScenario dans mon cas)

    Voici ma 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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fmp="http://www.filemaker.com/fmpdsoresult" exclude-result-prefixes="fmp">
       <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
       <xsl:key match="fmp:TLS_S_NomTache" name="cle" use="."/>
       <xsl:template match="/">
          <map>
          <xsl:attribute name="version"><xsl:text>0.7.1</xsl:text></xsl:attribute>
            <node>
            <xsl:attribute name="TEXT"><xsl:text>hypertim</xsl:text></xsl:attribute>
            <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
             <xsl:apply-templates select="//fmp:TLS_S_NomTache[generate-id(.)=generate-id(key('cle',.)[1])]"/>
            </node>
          </map>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomTache">
          <node>
             <xsl:attribute name="TEXT"><xsl:copy-of select="."/></xsl:attribute>
             <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>   
             <node>
                <xsl:attribute name="TEXT"><xsl:apply-templates select="//fmp:TLS_S_NomScenario[../fmp:TLS_S_NomTache=current()]"/></xsl:attribute>
                <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
             </node>
          </node>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomScenario">
          <xsl:copy-of select="."/>
       </xsl:template>
    </xsl:stylesheet>

  6. #6
    Futur Membre du Club
    Inscrit en
    Juillet 2005
    Messages
    8
    Détails du profil
    Informations forums :
    Inscription : Juillet 2005
    Messages : 8
    Points : 6
    Points
    6
    Par défaut
    j'avions un petit problème de vue....

    Je ne vois pas de code et je ne comprend pas ce qui est écrit?
    C'est normal chef où c'est une liste privée?

    ------------------------------------MON FICHIER XML
    Code:
    <FMPDSORESULT>
    <ROW>
    <TLS_S_NomTache>Tache1</TLS_S_NomTache>
    <TLS_S_Scenario>Scenario 1.1</TLS_S_Scenario>
    <TLS_TLA_NomTLA1>lot1.1</TLS_TLA_NomTLA1>
    <TLS_TLA_NomTLA2>lot1.2</TLS_TLA_NomTLA2>
    <TLS_TLA_NomTLA3>lot1.3</TLS_TLA_NomTLA3>
    </ROW>
    <ROW>
    <TLS_S_NomTache>Tache1</TLS_S_NomTache>
    <TLS_S_Scenario>Scenario 1.1</TLS_S_Scenario>
    <TLS_TLA_NomTLA1>lot2</TLS_TLA_NomTLA1>
    </ROW>
    <ROW>
    <TLS_S_NomTache>Tache2</TLS_S_NomTache>
    <TLS_S_Scenario>Scenario 2</TLS_S_Scenario>
    <TLS_TLA_NomTLA1>lot3</TLS_TLA_NomTLA1>
    </ROW>
    ...
    </FMPDSORESULT>


    ------------------------------------MON FICHIER XML de sortie
    Code:
    <map>
    <node TEXT="hypertim">
    <edge WIDTH="1" STYLE="bezier"/>
    <node TEXT="tache1" POSITION="right">
    <edge WIDTH="1" STYLE="bezier"/>
    <node TEXT="scenario1.1">
    <edge WIDTH="1" STYLE="bezier"/>
    <node TEXT="type de lot">
    <edge WIDTH="1" STYLE="bezier"/>
    <node TEXT="lot1.1"><edge WIDTH="1" STYLE="bezier"/></node>
    <node TEXT="lot1.2"><edge WIDTH="1" STYLE="bezier"/></node>
    <node TEXT="lot1.3"> <edge WIDTH="1" STYLE="bezier"/></node>
    </node>
    <node TEXT="lot2" />
    </node>
    <node TEXT="scenario1.2" />
    </node>
    <node TEXT="tache2" POSITION="right">
    <edge WIDTH="1" STYLE="bezier"/>
    <node TEXT="scenario2">
    <edge WIDTH="1" STYLE="bezier"/>
    <node TEXT="lot3"><edge WIDTH="1" STYLE="bezier"/></node>
    </node>
    </node>
    </node>
    </map>


    ------------------------------------MON 2eme FICHIER XSL
    Code:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fmp="http://www.filemaker.com/fmpdsoresult" exclude-result-prefixes="fmp">
    <xsl:output method="xml" encoding="iso-8859-1"/>

    <xsl:template match="fmp:FMPDSORESULT">
    <xsl:element name="map">
    <xsl:apply-templates select="*"/>
    </xsl:element>
    </xsl:template>

    <xsl:template match="fmp:ROW">
    <xsl:element name="node">
    <xsl:apply-templates select="*"/>
    </xsl:element>
    </xsl:template>

    <xsl:template match="*">
    <xsl:attribute name="TEXT"><xsl:value-of select="fmp:TLS_S_NomTache"/></xsl:attribute>
    <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
    <xsl:element name="edge">
    <xsl:attribute name="width"> <xsl:text>1</xsl:text></xsl:attribute>
    <xsl:attribute name="STYLE"><xsl:text>bezier</xsl:text></xsl:attribute>
    </xsl:element>
    </xsl:template>
    </xsl:stylesheet>
    en tout cas c'est plus lisible ainsi

  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 : 47
    Localisation : France

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 4 967
    Points : 10 927
    Points
    10 927
    Par défaut
    dans ce cas on refait une cle qui prend en compte le "parent" final



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:key match="b" name="cle2" use="concat(../a,.)"/>
    et on modifie l'appel

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <xsl:template match="a"> 
          <r1> 
             <xsl:copy-of select="."/> 
             <r2> 
                <xsl:apply-templates select="(//b[../a=current()])[generate-id(.)=generate-id(key('cle2',concat(.,../b))[1])]"/> 
             </r2> 
          </r1> 
       </xsl:template>
    Simplement l'idee, pas teste le code

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut
    Merci Erwy,
    J'ai bien fait ce que tu m'as indiqué mais sans succès. Voici mon xsl, peut-être ai-je mal repris ton code.
    Merci bcp.

    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
     
       <xsl:key match="fmp:TLS_S_NomTache" name="cle" use="."/>
       <xsl:key match="fmp:TLS_S_NomScenario" name="cle2" use="concat(../fmp:TLS_S_NomTache,.)"/>
       <xsl:template match="/">
          <map>
          <xsl:attribute name="version"><xsl:text>0.7.1</xsl:text></xsl:attribute>
            <node>
            <xsl:attribute name="TEXT"><xsl:text>hypertim</xsl:text></xsl:attribute>
            <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
             <xsl:apply-templates select="//fmp:TLS_S_NomTache[generate-id(.)=generate-id(key('cle',.)[1])]"/>
            </node>
          </map>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomTache">
          <node>
             <xsl:attribute name="TEXT"><xsl:copy-of select="."/></xsl:attribute>
             <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>   
             <node>
                <xsl:attribute name="TEXT"><xsl:apply-templates 
     
    select="(//fmp:TLS_S_NomScenario[../fmp:TLS_S_NomTache=current()])[generate-id(.)=generate-id(key('cle2',concat(.,../fmp:TLS_S_NomScenario))[1])]"/></xsl:attribute>
                <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
             </node>
          </node>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomScenario">
          <xsl:copy-of select="."/>
       </xsl:template>

  9. #9
    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 : 47
    Localisation : France

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 4 967
    Points : 10 927
    Points
    10 927
    Par défaut
    erreur dans l'appel
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
          <xsl:apply-templates select="(//b[../a=current()])[generate-id(.)=generate-id(key('cle2',concat(../a,.))[1])]"/>
    J'avais inversé, même chose que dans la cle finalement

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut
    J'ai bien remplacé :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:apply-templates select="(//b[../a=current()])[generate-id(.)=generate-id(key('cle2',concat(.,../b))[1])]"/>
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      <xsl:apply-templates select="(//b[../a=current()])[generate-id(.)=generate-id(key('cle2',concat(../a,.))[1])]"/>
    Mais sans résultat. Qu'entends par : "J'avais inversé, même chose que dans la cle finalement"

    Merci bcp

  11. #11
    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 : 47
    Localisation : France

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

    Informations forums :
    Inscription : Novembre 2003
    Messages : 4 967
    Points : 10 927
    Points
    10 927
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <xsl:key match="b" name="cle2" use="concat(../a,.)"/>
    ../a,. identique
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      <xsl:apply-templates select="(//b[../a=current()])[generate-id(.)=generate-id(key('cle2',concat(../a,.))[1])]"/>
    Teste avec succes sur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" encoding="UTF-8"?>
    <D>
    <r><a>1</a><b>a</b></r>
    <r><a>1</a><b>a</b></r>
    <r><a>1</a><b>b</b></r>
    <r><a>2</a><b>a</b></r>
    <r><a>2</a><b>a</b></r>
    <r><a>3</a><b>b</b></r>
    </D>

  12. #12
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut
    je récupère bien les les sous niveau (b) mais tout il me colle tout le contenu dans la balise (ici un attribut TEXT="").
    Dois-je faire une boucle ou .. ?
    Merci bcp

    Voici mon code :
    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
       <xsl:key match="fmp:TLS_S_NomTache" name="cle" use="."/>
       <xsl:key match="fmp:TLS_S_NomScenario" name="cle2" use="concat(../fmp:TLS_S_NomTache,.)"/>
       <xsl:template match="/">
          <map>
          <xsl:attribute name="version"><xsl:text>0.7.1</xsl:text></xsl:attribute>
            <node>
            <xsl:attribute name="TEXT"><xsl:text>hypertim</xsl:text></xsl:attribute>
            <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
             <xsl:apply-templates select="//fmp:TLS_S_NomTache[generate-id(.)=generate-id(key('cle',.)[1])]"/>
            </node>
          </map>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomTache">
          <node>
             <xsl:attribute name="TEXT"><xsl:copy-of select="."/></xsl:attribute>
             <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>   
             <node>
                <xsl:attribute name="TEXT"><xsl:apply-templates 
     
    select="(//fmp:TLS_S_NomScenario[../fmp:TLS_S_NomTache=current()])[generate-id(.)=generate-id(key('cle2',concat(../fmp:TLS_S_NomTache,.))[1])]"/></xsl:attribute>
                <xsl:attribute name="POSITION"><xsl:text>right</xsl:text></xsl:attribute>
             </node>
          </node>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomScenario">
          <xsl:copy-of select="."/>
       </xsl:template>

  13. #13
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2005
    Messages
    56
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 56
    Points : 28
    Points
    28
    Par défaut
    C'est ok, ça marche bien, merci
    Par revanche, j'ai essayé de rajouter un niveau, mais ça fonctionne que partiellement.

    Voici ce que j'ai :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <D>
    <r><a>1</a><b>a</b><c1>xxx</c1></r>
    <r><a>1</a><b>a</b><c1>kkk</c1></r>
    <r><a>1</a><b>b</b><c1>lll</c1></r>
    <r><a>2</a><b>a</b><c1>ggg</c1></r>
    <r><a>2</a><b>a</b><c1>ttt</c1></r>
    <r><a>3</a><b>b</b><c1>rrr</c1></r>
    </D>
    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
    <racine>
       <r1>
          <a>1</a>
          <r2>
             <b>a</b>
             <r3>
                <c1></c1> (mais juste ceux ayant le même contenu de <b>)
                <c1></c1>
             </r3>
             <b>b</b>
          </r2>
       </r1>
       <r1>
          <a>2</a>
          <r2>
             <b>a</b>
          </r2>
       </r1>
       <r1>
          <a>3</a>
          <r2>
             <b>b</b>
          </r2>
       </r1>
    </racine>
    Voici ma XSL, ici je récupère tout les c1 de tous les noeuds r :

    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
       <xsl:key match="fmp:TLS_S_NomTache" name="cle" use="."/>
       <xsl:key match="fmp:TLS_S_NomScenario" name="cle2" use="concat(../fmp:TLS_S_NomTache,.)"/>
       <xsl:template match="/">
          <map>
            <node>
            <xsl:attribute name="TEXT"><xsl:text>hypertim</xsl:text></xsl:attribute>
             <xsl:apply-templates select="//fmp:TLS_S_NomTache[generate-id(.)=generate-id(key('cle',.)[1])]"/>
            </node>
          </map>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomTache">
          <node>
             <xsl:attribute name="TEXT"><xsl:copy-of select="."/></xsl:attribute>
             <xsl:apply-templates 
     
    select="(//fmp:TLS_S_NomScenario[../fmp:TLS_S_NomTache=current()])[generate-id(.)=generate-id(key('cle2',concat(../fmp:TLS_S_NomTache,.))[1])]"/>
     
          </node>
       </xsl:template>
       <xsl:template match="fmp:TLS_S_NomScenario">
        <node>
          <xsl:attribute name="TEXT"><xsl:copy-of select="."/></xsl:attribute>
          <xsl:apply-templates select="//fmp:TLS_TLA_NomTLA1"/>
        </node>
       </xsl:template>
     
       <xsl:template match="fmp:TLS_TLA_NomTLA1">
        <node>
          <xsl:attribute name="TEXT"><xsl:copy-of select="."/></xsl:attribute>
        </node>
       </xsl:template>

Discussions similaires

  1. Réponses: 2
    Dernier message: 15/04/2014, 14h58
  2. [XSLT 1.0] problème de récursivité d'un fichier XSL
    Par yous_han dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 04/05/2011, 15h00
  3. Réponses: 0
    Dernier message: 03/03/2011, 14h16
  4. [XSL]Impossible d'utiliser les fonctions XPath 2.0
    Par cvmz dans le forum XSL/XSLT/XPATH
    Réponses: 4
    Dernier message: 27/03/2006, 19h19
  5. [XSL] impossible d'utiliser variable dans expression XPATH
    Par pierre.zelb dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 18/01/2006, 07h41

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