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-FO] générer un pdf


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 11
    Points : 9
    Points
    9
    Par défaut [XSL-FO] générer un pdf
    Bonjour,

    Depuis mon message d'avant hier, j'ai retravaillé le fichier xls-fo, toutefois je n'arrive toujours pas à obtenir sous une ue tous les modules et évaluation.
    Le fichier xml est généré par une application et je cherche
    à faire un relevé de notes en pdf. Pour l'instant le premier module et la première évaluation apparaissent.


    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
    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" encoding="iso-8859-1"?>
    <carnet>
    <etudiant  nom="fleur" prenom="rose" sexe="Mle" />
    <note value="14.12"/>
    <rang ninscrits="9" value="1"/>
    <note_max value="20"/>
     
    <ue code="UE 1.1" titre="economie" numero="2" >
    <rang ninscrits="15" value="1"/>
    <note value="13.00"/>
     
    <module coef="1.0" code="S10"  titre="Initiation" >
    <note value="13.00"/>
     
    <evaluation coef="1.0" description="controle" numero="5">
    <note value="14.00"/>
    </evaluation>
    </module>
    <module coef="1.0" code="S20"  titre="Intermédiaire" >
    <note value="11.00"/>
     
    <evaluation coef="1.0" description="oral">
    <note value="18.00"/>
    </evaluation>
    </module>
    </ue>
     
    <ue code="UE 1.2" titre="gestion" numero="6" >
    <note value="13.00"/>
     
    <module coef="1.0" code="G30"  titre="Initiation" >
    <note value="10.00"/>
     
    <evaluation coef="1.0"  description="dossier">
    <note value="11.00"/>
    </evaluation>
    </module>
    <module coef="1.0" code="G50"  titre="Intermédiaire" >
    <note value="13.00"/>
     
    <evaluation coef="1.0" description="controle">
    <note value="16.00"/>
    </evaluation>
    </module>
    </ue>
     
    <ue code="UE 2" titre="anglais" numero="7">
    <note value="13.00"/>
     
    <module coef="1.0" code="A130"  titre="Initiation" >
    <note value="8.00"/>
     
    <evaluation coef="1.0"  description="oral">
    <note value="9.00"/>
    </evaluation>
    </module>
    </ue>
    </carnet>
    fichier xsl-fo
    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
     
    <?xml version="1.0" encoding="iso-8859-2"?>
    <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="/">
    <fo:root> 
    <fo:layout-master-set> 
    <fo:simple-page-master master-name="exemple"                
    	  page-height="29.7cm"              page-width="21cm"            
    	  margin-top="1cm"                   margin-bottom="2cm"                  
    	 margin-left="1.5cm"                   margin-right="1.5cm">   
    <fo:region-body margin-top="3cm" margin-bottom="1.5cm" column-count="3"/>   
    <fo:region-before extent="3cm"/>     
         <fo:region-after extent="1.5cm"/> 
        </fo:simple-page-master>  </fo:layout-master-set> 
        <fo:page-sequence master-reference="exemple">   
        <fo:flow flow-name="xsl-region-body"> 
       <fo:block text-indent="0pc" space-after="7pt"   space-before.minimum="6pt" space-before.optimum="8pt"     space-before.maximum="10pt"><xsl:text> Relevé de notes de </xsl:text><xsl:value-of select="carnet/etudiant/@sexe" /> <xsl:text> </xsl:text> <xsl:value-of select="carnet/etudiant/@nom" /> <xsl:text> </xsl:text>  <xsl:value-of select="carnet/etudiant/@prenom" />  
    </fo:block>   
    <fo:table table-layout="fixed" width="100%" border-bottom="1px solid #ccc"
                  	font-size=".9em" color="#666">
                   	<fo:table-column column-width="3cm" />
                    	<fo:table-column column-width="6cm" />
                    	<fo:table-column column-width="4cm" />
    		<fo:table-column column-width="3cm" />
    		<fo:table-column column-width="2cm" />
    	<fo:table-header>
    		<fo:table-cell>
                             <fo:block>
                                   <xsl:text> Moyenne</xsl:text></fo:block>
    		</fo:table-cell>
    		 <fo:table-cell>
                              <fo:block>
                               <!--Récupération de la moyenne de l'étudiant -->
                                <xsl:value-of select="carnet/ue/note/@value" /></fo:block>
    		</fo:table-cell>
    		<fo:table-cell>
                              <fo:block>
    		<xsl:text> Rang </xsl:text>						  
                               <!--Récupération du rang de l'étudiant -->
                                <xsl:value-of select="carnet/ue/rang/@value" />           <xsl:text>/</xsl:text>
                                    <!--Récupération du nombre d'inscrits -->
                                    <xsl:value-of select="carnet/ue/rang/@ninscrits" /></fo:block>
    		</fo:table-cell>
    		<fo:table-cell>
                              <fo:block>
    		<xsl:text> Notes /</xsl:text>
    		  <!--Récupération de la note max -->
                              <xsl:value-of select="carnet/ue/note_max/@value" />
    		</fo:block>
    		</fo:table-cell>
    	</fo:table-header>
    	<fo:table-body>
    <xsl:apply-templates  select="carnet/ue" /> 
    	</fo:table-body>
    	</fo:table>
    	</fo:flow>
    </fo:page-sequence> 
    </fo:root> 	
    </xsl:template>
            <!--Récupération du code, titre, note du module-->
     
    	<xsl:template match="carnet/ue">	 
    		<fo:table-row >
    		<fo:table-cell background-color="#E0FEFE">
                               <fo:block ><xsl:value-of select="@code" /></fo:block>
    		</fo:table-cell>
    		<fo:table-cell background-color="#E0FEFE">
                              <fo:block ><xsl:value-of select="@titre" /></fo:block>
                              </fo:table-cell>  
                              <fo:table-cell background-color="#E0FEFE">
    		<fo:block ><xsl:text> </xsl:text> </fo:block>
    		</fo:table-cell>   
    		<fo:table-cell background-color="#E0FEFE">
                              <fo:block >
    		<xsl:value-of select="note/@value" />  
                               </fo:block></fo:table-cell>
    		<fo:table-cell background-color="#E0FEFE">                        
    		<fo:block >				      
                                <xsl:text> </xsl:text></fo:block>			
    		</fo:table-cell> 
    		</fo:table-row>		
    		 <fo:table-row >
    		<fo:table-cell background-color="yellow">
                               <fo:block ><xsl:value-of select="module/@code" /></fo:block>
    		</fo:table-cell>
    		<fo:table-cell background-color="yellow">
                             	 <fo:block ><xsl:value-of select="module/@titre" />
                               </fo:block>
    		</fo:table-cell>  
                            <fo:table-cell background-color="yellow">				  <fo:block ><xsl:text> </xsl:text> 					  </fo:block>
    		</fo:table-cell>   
    		<fo:table-cell background-color="yellow">
                              <fo:block >
    		<xsl:value-of select="module/note/@value" />  
                               </fo:block>
    		</fo:table-cell>				  	 
    		<fo:table-cell background-color="yellow">
    		<fo:block >				       
                                <xsl:value-of select="module/@coef" />  </fo:block>
    		</fo:table-cell>			
    		</fo:table-row>
    		<fo:table-row >
    		<fo:table-cell>
                              <fo:block>
    		<xsl:text> </xsl:text> </fo:block>
    		</fo:table-cell>
    		<fo:table-cell >
      <!--Récupération des evaluations des modules avec leur description, note et coef -->
     
                                <fo:block ><xsl:value-of select="module/evaluation/@description" />						</fo:block></fo:table-cell>
    		<fo:table-cell >							  <fo:block ><xsl:text> </xsl:text> </fo:block>
    		</fo:table-cell>                                  
    		<fo:table-cell >
                              <fo:block >
        		 <xsl:value-of select="module/evaluation/note/@value" />  
                                 </fo:block></fo:table-cell>
    		<fo:table-cell >						            <fo:block >				       
                             <xsl:value-of select="module/evaluation/@coef" />  
                              </fo:block>					             </fo:table-cell>			
    		</fo:table-row>					
    </xsl:template>		  	
    </xsl:stylesheet>
    Le code est un peu long et je m'en excuse.
    Je bloque depuis plusieurs jours: toutes les ue apparaissent mais seul le premier module et la première évaluation apparaissent pour l'ue concernée. J'ai essayé des boucles <xsl:for-each select=""> sans succès. Qui pourrait m'aider à progresser sur ce fichier.
    Merci d'avance.
    Cordialement,
    Images attachées Images attachées
    Fichiers attachés Fichiers attachés

  2. #2
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 11
    Points : 9
    Points
    9
    Par défaut
    Bonsoir,

    Après beaucoup de tests, j'ai modifié mon fichier avec deux templates supplémentaires et des chemins mieux définis.
    Cela fonctionne enfin. Voilà le 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
    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
    <?xml version="1.0" encoding="iso-8859-2"?>
    <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="/">
    <fo:root> 
    <fo:layout-master-set> 
        <fo:simple-page-master master-name="exemple"                
    	  page-height="29.7cm"                   page-width="21cm"            
    	        margin-top="1cm"                   margin-bottom="2cm"                  
    			 margin-left="1.5cm"                   margin-right="1.5cm">   
     
    	  <fo:region-body margin-top="3cm" margin-bottom="1.5cm" column-count="3"/>   
    	     <fo:region-before extent="3cm"/>     
    		  <fo:region-after extent="1.5cm"/> 
    		   </fo:simple-page-master>  </fo:layout-master-set> 
    		      <fo:page-sequence master-reference="exemple">   
    			   <fo:flow flow-name="xsl-region-body"> 
    			        <fo:block text-indent="0pc" space-after="7pt"       
    					    space-before.minimum="6pt" space-before.optimum="8pt"       
    						space-before.maximum="10pt"><xsl:text> Relevé de notes de </xsl:text><xsl:value-of select="carnet/etudiant/@sexe" /> <xsl:text> </xsl:text> <xsl:value-of select="carnet/etudiant/@nom" /> <xsl:text> </xsl:text>  <xsl:value-of select="carnet/etudiant/@prenom" />  
    					   </fo:block>   
     
                             <fo:block>
                                   <xsl:text> Moyenne</xsl:text></fo:block>
     
                              <fo:block>
                                    <!--Récupération de la moyenne de l'étudiant -->
                                    <xsl:value-of select="carnet/note/@value" /></fo:block>
     
                              <fo:block>
    						  <xsl:text> Rang </xsl:text>						  
                                    <!--Récupération du rang de l'étudiant -->
                                    <xsl:value-of select="carnet/rang/@value" />  <xsl:text>/</xsl:text>
                                    <!--Récupération du nombre d'inscrits -->
                                    <xsl:value-of select="carnet/rang/@ninscrits" /></fo:block>
     
                              <fo:block>
    						  <xsl:text> Notes /</xsl:text>
    						        <!--Récupération de la note max -->
                              <xsl:value-of select="carnet/note_max/@value" />
    						  </fo:block>
     
    			<fo:block>					<xsl:apply-templates  select="carnet/ue"/> 
    					</fo:block>
     
    			 	</fo:flow>
    		</fo:page-sequence> 
    	</fo:root> 
     
    	</xsl:template>
     
     
    <xsl:template match="carnet/ue">
     
     
                                <fo:block ><xsl:value-of select="@code" /></fo:block>
     
                              <fo:block ><xsl:value-of select="@titre" /></fo:block>
     
    							<fo:block ><xsl:text> </xsl:text> </fo:block>
     
                              <fo:block >
    						        <xsl:value-of select="note/@value" /> </fo:block>	 
     
    						<fo:block >						      
                                    <xsl:text> </xsl:text></fo:block>	
    													<xsl:apply-templates select="module"/>
     
    </xsl:template>
    <xsl:template match="module">
     
                                <fo:block ><xsl:value-of select="@code" /></fo:block>
     
                             	 <fo:block ><xsl:value-of select="@titre" />
                                 </fo:block>
     
    							  <fo:block ><xsl:text> </xsl:text> 
    							  </fo:block>
     
                              	<fo:block >
    						        <xsl:value-of select="note/@value" />  
                                 </fo:block>
     
    							<fo:block >						       
                                     <xsl:value-of select="@coef" />  </fo:block>
    								<xsl:apply-templates select="evaluation"/>
     
     
    	</xsl:template>
    <xsl:template match="evaluation">
     
                              <fo:block>
    						  <xsl:text> </xsl:text> </fo:block>
     
                                <fo:block ><xsl:value-of select="@description" />
    							</fo:block>
    							  <fo:block ><xsl:text> </xsl:text> </fo:block>
     
                              <fo:block >						
                                    <xsl:value-of select="note/@value" />  
                                 </fo:block>
     
    						    <fo:block >						       
                                     <xsl:value-of select="@coef" />  </fo:block>
     
     
    		 </xsl:template>	
     
     
    </xsl:stylesheet>
    A bientôt,

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Générer un PDF en Java
    Par joneil dans le forum Documents
    Réponses: 7
    Dernier message: 25/02/2012, 15h14
  2. [XSL-FO] Générer un PDF depuis une source XML
    Par Ildegarde dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 25/01/2010, 14h03
  3. Générer du pdf
    Par illegalsene dans le forum Documents
    Réponses: 5
    Dernier message: 04/05/2005, 14h20
  4. Librairies gratuites pour générer du PDF
    Par Noxexplorer dans le forum ASP
    Réponses: 2
    Dernier message: 02/05/2005, 20h18
  5. [XSL-FO] xml vers xsl-fo (pour generation PDF ou RTF)
    Par dams50 dans le forum XSL/XSLT/XPATH
    Réponses: 5
    Dernier message: 13/12/2003, 21h07

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