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] tableau à colonnes variables


Sujet :

XSL/XSLT/XPATH XML

  1. #1
    Candidat au Club
    Inscrit en
    Avril 2005
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2005
    Messages : 3
    Points : 2
    Points
    2
    Par défaut [XSL~FO] tableau à colonnes variables
    Bonjour,

    Je souhaite pouvoir creer un pdf pr imprimer certaines tables !
    Débutant avec cette tech., je rencontre certains pb dont :

    les tables à imprimer ont un nombre de colonnes variables ! (le titre de la colonne correspont à une période : 01/2006, 02/2006 ...)

    voici le doc xml produit :

    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <ind1>
    <entete>
    <date>13/09/2006</date>
    </entete>
    <tableInd>
    <mois>01/06</mois>
    <mois>02/06</mois>
    <mois>03/06</mois>
    <mois>04/06</mois>
    <mois>05/06</mois>
    <mois>06/06</mois>
    <mois>07/06</mois>
    <mois>08/06</mois>
    <mois>09/06</mois>
    <ind1Body>
    <nom>XVD</nom>
    <indice>-1.0</indice>
    <indice>10.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>18.33</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    </ind1Body>
    <ind1Body>
    <nom>FGT</nom>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    <indice>-1.0</indice>
    </ind1Body>
    </tableInd>
    </ind1>

    voici mon 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
    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
      <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
     
      <xsl:template match="ind1">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
     
          <fo:layout-master-set>
            <fo:simple-page-master 
            	master-name="simpleA4" 
            	page-height="29.7cm" 
            	page-width="21cm" 
            	margin-top="0.5cm" 
            	margin-bottom="0.5cm" 
            	margin-left="0.5cm" 
            	margin-right="0.5cm">
    		  <fo:region-before extent="3cm"/>
              <fo:region-after extent="0.6cm"/>
              <fo:region-body margin-top="3.20cm" margin-bottom="1.5cm"/>
            </fo:simple-page-master>
          </fo:layout-master-set>
     
          <fo:page-sequence master-reference="simpleA4">    
     
    		  <fo:static-content flow-name="xsl-region-before">
    			<fo:block>
    				<xsl:apply-templates select="entete"/>
    			</fo:block>
    		  </fo:static-content>
     
    		  <fo:static-content flow-name="xsl-region-after">
    			<fo:block font-size="8pt" text-align="right" font-weight="bold" space-before="0.2cm">
    			    Page <fo:page-number/> sur <fo:page-number-citation ref-id="ref-derniere-page"/>
    		    </fo:block>
    		  </fo:static-content>
     
            <fo:flow flow-name="xsl-region-body">
    			<xsl:apply-templates select="tableInd"/>
    			<fo:block id="ref-derniere-page"/>
            </fo:flow>
          </fo:page-sequence>
     
        </fo:root>
      </xsl:template>
     
      <xsl:template match="entete">
     
      	<fo:table space-after="0.5cm">
    		<fo:table-column column-width="6.5cm"/>
    		<fo:table-column column-width="13.5cm"/>
    		<fo:table-body>
    			<fo:table-row height="1.7cm">
    				<fo:table-cell border="0.5pt solid white" display-align="center"> 
    					<fo:external-graphic src="img.gif" width="4cm"/>
    				</fo:table-cell>	
    				<fo:table-cell border="0.5pt solid black" display-align="center">
    					<fo:block font-size="24pt" text-align="center" font-weight="bold" space-after="0.2cm"> NOTE </fo:block>
    					<fo:block font-size="10pt" text-align="right" font-weight="bold" margin-left="0.2cm">Date: <xsl:value-of select="date"/></fo:block>
    				</fo:table-cell>	
    			</fo:table-row>
    		</fo:table-body>
    	</fo:table>
     
      </xsl:template>
     
      <xsl:template match="tableInd">
     
    	<fo:table>
    		<fo:table-column column-width="1.8cm"/>
    		<xsl:for-each select="ind1/tableInd/mois">
    			<fo:table-column column-width="1.4cm"/>
    		</xsl:for-each>
     
    		<fo:table-header>
    			  <fo:table-row  height="0.8cm" text-align="center" font-size="10pt" display-align="center" font-weight="bold" >
    					<fo:table-cell  border="1pt solid black">
    						<fo:block>A/D</fo:block>
    					</fo:table-cell>
    					<fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block><xsl:value-of select="mois"/></fo:block>
        	  </fo:table-cell>
    				  <fo:table-cell  border="1pt solid black">
    					<fo:block>Total</fo:block>
        	  </fo:table-cell>
    			  </fo:table-row>
    		</fo:table-header>
     
    		<fo:table-body>
    			<xsl:apply-templates select="ind1Body"/>
    		</fo:table-body>
    	</fo:table>
     
      </xsl:template>
     
    	<xsl:template match="ind1Body">
    			<fo:table-row height="0.44cm" text-align="center" font-size="7pt" display-align="center" wrap-option="no-wrap">
    				<fo:table-cell border="1pt solid black">
    					<fo:block>
    						<xsl:value-of select="nom"/>
    					</fo:block>
    				</fo:table-cell>
    				<xsl:apply-templates select="indice"/>
    	        </fo:table-row>
        </xsl:template>
     
    	<xsl:template match="indice">
    		  <fo:table-cell border="1pt solid black">
    			  <fo:block>
    				  <xsl:value-of select="indice"/>
    			  </fo:block>
    		  </fo:table-cell>
    	</xsl:template>
     
    </xsl:stylesheet>
    mon fichier xml vs semble t'il correct?
    est on obliger de specifier le nombre de colonne du moins, indiquer à chaque fois sa taille :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <fo:table-column column-width="1.4cm"/>
    le tableau ne peut il pas s'auto dimensionner?

    ou puis je trouver de la doc?

    merci

  2. #2
    Membre expérimenté
    Avatar de virgul
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    1 625
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Suisse

    Informations forums :
    Inscription : Novembre 2004
    Messages : 1 625
    Points : 1 666
    Points
    1 666
    Par défaut
    Salut,

    ouais ca risque d'être compliqué a faire tout ca....


    Moi ce que je te conseil vu que tu dois connaitre la longueur total du tableau c'est de le diviser par ton nombre de date a représenté et après de faire une boucle boucle créer tes colonne avec comme longueur le résultat du précédent calcul.

    Après faut voir si tu veux faire le calcul dans ce xslt ou déjà l'inclure dans ton XML ou encore la passé en paramètre dans ta feuille de style.


    ++

    Thierry
    "Life is short don't forget to inhale"
    Mais: "Mieux vaux arriver en retard dans ce monde... qu'en avance à l'autre."

  3. #3
    Membre éclairé
    Inscrit en
    Octobre 2005
    Messages
    847
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 847
    Points : 841
    Points
    841
    Par défaut
    c'est pas trés compliqué normalement (enfin si j'ai bien compris)

    - le nombre de balise mois peut varier?

    si c'est le cas, il faut faire :

    - stocker ceci

    dans une variable xsl


    -quand tu arrive dans un
    il faut compter les <mois> (nombreMois)

    - ensuite créer une variable "colWidth" à laquelle tu affecte le resultat de :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    page-width div nombreMois
    - affecte colWidth comme largeur de tes colonnes.
    et voila la largeur de tes colonnes s'adapte en fonction du nombre de celles-ci.


    j'espere que tu as compris (et surtout que moi j'ai compris )
    Ce n’est pas en cassant le thermomètre que vous ferez baisser la température

  4. #4
    Candidat au Club
    Inscrit en
    Avril 2005
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2005
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    si tu as compris

    ben v essayer ... merci !

  5. #5
    Membre éclairé
    Inscrit en
    Octobre 2005
    Messages
    847
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 847
    Points : 841
    Points
    841
    Par défaut
    réviens nous voir si tu rencontre des difficultés..
    Ce n’est pas en cassant le thermomètre que vous ferez baisser la température

Discussions similaires

  1. tableau richdatable colonne variable
    Par homonxa dans le forum JSF
    Réponses: 3
    Dernier message: 11/06/2010, 09h59
  2. [MCD] stocker un tableau a colonnes variables
    Par riadh2406 dans le forum Schéma
    Réponses: 3
    Dernier message: 21/10/2009, 13h51
  3. [xsl-fo]Tableau dynamique et variable
    Par Little_flower dans le forum XSL/XSLT/XPATH
    Réponses: 8
    Dernier message: 23/05/2007, 16h46
  4. Réponses: 1
    Dernier message: 05/01/2007, 15h33
  5. javascript pour tableau à largeur de colonnes variables
    Par barkleyone dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 06/06/2006, 17h14

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