Cliquez ici.
Accueil
 chercher             Plan du site             Info (English version) 
L'histoire de XML s'écrit en ce moment même. XMLfr vous aide à la suivre et à en dégager les tendances.Les listes de discussions XMLfr sont à votre disposition pour réagir sur nos articles ou simplement poser une question.Si vous ètes passionnée(e) par XML, pourquoi ne pas en faire votre métier ?XMLfr n'est heureusement pas le seul site où l'on parle de XML. Découvrez les autres grâce à XMLfr et à l'ODP.Les partenaires grâce auxquels XMLfr peut se développer.Pour tout savoir sur XMLfr.XMLfr sans fil, c'est possible !Pour ceux qui veulent vraiment en savoir plus sur XML.L'index du site.
 Commentaires et questions non techniques.Commentaires et questions techniques.

 
Cliquez ici.

From: Jerome TRUFFOT (jerome.truffot@isima.fr)
Date: 06/02/2004 - 10:22


Peut-être un truc comme ça :

<xsl:template match="/">
    <table>
    <tr>
    <th>POIDS (Kg)</th>
    <xsl:for-each select="secteur">
    <xsl:sort select="code_sect_tarif"/>
    <th>Secteur <xsl:value-of select="code_sect_tarif"/></th>
    </xsl:for-each>
    </tr>
   
    <xsl:call-template name="poidsSup">
        <xsl:with-param name="poidsinf" select="0"/>
        <xsl:with-param name="poidssup" select="30"/>
        <xsl:with-param name="position" select="0"/>
    </xsl:call-template>
    </table>
</xsl:template>

<xsl:template name="poidsSup"> <!-- Calcul du plus petit poids sup
suivant -->
    <xsl:param name="poidsinf"/>
    <xsl:param name="poidssup"/>
    <xsl:param name="position"/>

    <xsl:choose>
        <xs:when test="position <= count(secteur)">
            <xsl:choose>
                <xsl:when test="secteur[position() =
position]/tarif[@poids_inf <= $poidsinf and @poids_sup >=
$poidsinf]/@poids_sup < poidssup">
                    <xsl:call-template name="poidsMin">
                        <xsl:with-param name="poidsinf" select="$poidsinf"/>
                        <xsl:with-param name="poidssup"
select="secteur[position() = position]/tarif[@poids_inf <= $poids and
@poids_sup >= $poids]/@poids_sup"/>
                        <xsl:with-param name="position"
select="$position + 1"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="poidsMin">
                        <xsl:with-param name="poidsinf" select="$poidsinf"/>
                        <xsl:with-param name="poidssup" select="$poidssup"/>
                        <xsl:with-param name="position"
select="$position + 1"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
            <xsl:call-template name="ligne">
                <xsl:with-param name="poidsinf" select="poidsinf"/>
                <xsl:with-param name="poidssup" select="poidsup"/>
            </xsl:call-template>
       </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="ligne"> <!-- affichage de la liste -->
    <xsl:param name="poidsinf"/>
    <xsl:param name="poidssup"/>

    <xsl:if test="$poidsinf < 30">
        <tr>
        <td><xsl:value-of select="$poidsinf"/> - <xsl:value-of
select="$poidssup"/></td>
        <xsl:for-each select="secteur">
        <xsl:sort select="code_sect_tarif"/>
            <td><xsl:value-of select="tarif[@poids_inf <= $poidsinf and
@poids_sup >= $poidsinf]/@prix"/></td>
        </xsl:for-each>
        <tr>

        <xsl:call-template name="poidsSup">
            <xsl:with-param name="poidsinf" select="$poidssup"/>
            <xsl:with-param name="poidssup" select="30"/>
            <xsl:with-param name="position" select="1"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>

L'idée est de parcourir les secteurs à la recherche du plus petit
poids_sup suivant puis d'afficher la ligne en conséquence.

Amicalement.

Jérôme

jianxin.kong@telintrans.fr wrote:

>
>Bonjour à tous !
>
>J'ai un fichier XML en entrée avec les données tarifaires (See attached file:
>Tarifs.xml), et je voudrais générer un tableau tarifaire suivant via une
>transformation XSLT:
>|---------------+---------------+---------------+--------------->
>| POIDS(Kg) | Secteut 1 | Secteur 2 | ....... |
>| (poids_inf - | (prix) | (prix) | |
>| poids_sup ) | | | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | Secteur 8 |
> | (prix) |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 0,00-0,50 | 6,20 | 14,87 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 46,36 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 0,50-1,00 | 6,20 | 15,62 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 50,84 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 1,00-1,50 | 6,20 | 16,36 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 55,33 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 1,50-2,00 | 6,20 | 17,10 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 59,82 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 2,00-2,50 | 6,20 | 17,85 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 64,30 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 2,50-3,00 | 6,20 | 18,24 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 68,79 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 3,00-3,50 | 6,20 | 18,64 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 90,06 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 3,50-4,00 | 6,20 | 19,04 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 94,97 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 4,00-4,50 | 6,20 | 19,43 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 99,88 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 4,50-5,00 | 6,20 | 19,83 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 104,78 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 5,00-5,50 | 6,69 | 20,18 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 109,69 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 5,50-6,00 | 6,69 | 20,53 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 114,60 |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| ........ | ........ | ........ | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | ........ |
> >---------------|
>|---------------+---------------+---------------+--------------->
>| 29,50-30,00 | 8,68 | 33,22 | |
>|---------------+---------------+---------------+--------------->
> >---------------|
> | 350,25 |
> >---------------|
>
>
>
>Mon problème, c'est le suivant:
>sur certains secteurs, les données tarifaire (prix) sont compressés dont les
>tranches de poids (poids_inf - poids_sup) sont différentes. Par exemple,
>
> <secteur code_sect_tarif=""1">
> <tarif poids_inf="0,0" poids_sup="5,0" prix="6,20" unite_kg="0,5"
>prix_unite=""/>
> <tarif poids_inf="5,0" poids_sup="10,0" prix="6,69" unite_kg="0,5"
>prix_unite=""/>
> <tarif poids_inf="10,0" poids_sup="20,0" prix="7,68" unite_kg="0,5"
>prix_unite=""/>
> <tarif poids_inf="20,0" poids_sup="30,0" prix="8,68" unite_kg="0,5"
>prix_unite=""/>
> </secteur>
> <secteur code_sect_tarif="2">
> <tarif poids_inf="0,0" poids_sup="0,5" prix="14,87" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="0,5" poids_sup="1,0" prix="15,62" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="1,0" poids_sup="1,5" prix="16,36" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="1,5" poids_sup="2,0" prix="17,10" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="2,0" poids_sup="2,5" prix="17,85" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="2,5" poids_sup="3,0" prix="18,24" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="3,0" poids_sup="3,5" prix="18,64" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="3,5" poids_sup="4,0" prix="19,04" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="4,0" poids_sup="4,5" prix="19,43" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="4,5" poids_sup="5,0" prix="19,83" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="5,0" poids_sup="5,5" prix="20,18" unite_kg=""
>prix_unite=""/>
> </secteur>
> <secteur code_sect_tarif="3">
> <tarif poids_inf="0,0" poids_sup="0,5" prix="18,10" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="0,5" poids_sup="1,0" prix="19,09" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="1,0" poids_sup="1,5" prix="20,08" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="1,5" poids_sup="2,0" prix="21,07" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="2,0" poids_sup="2,5" prix="22,06" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="2,5" poids_sup="3,0" prix="23,05" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="3,0" poids_sup="3,5" prix="24,05" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="3,5" poids_sup="4,0" prix="25,04" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="4,0" poids_sup="4,5" prix="26,03" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="4,5" poids_sup="5,0" prix="27,02" unite_kg=""
>prix_unite=""/>
> </secteur>
>............................................
>
> <secteur code_sect_tarif="8">
> <tarif poids_inf="0,0" poids_sup="0,5" prix="46,36" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="0,5" poids_sup="1,0" prix="50,84" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="1,0" poids_sup="1,5" prix="55,33" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="1,5" poids_sup="2,0" prix="59,82" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="2,0" poids_sup="2,5" prix="64,30" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="2,5" poids_sup="3,0" prix="68,79" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="3,0" poids_sup="3,5" prix="90,06" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="3,5" poids_sup="4,0" prix="94,97" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="4,0" poids_sup="4,5" prix="99,88" unite_kg=""
>prix_unite=""/>
> <tarif poids_inf="4,5" poids_sup="5,0" prix="104,78" unite_kg=""
>prix_unite=""/>
> </secteur>
>
>Est-ce qu'il est possible de faire en même temps la décompression et la mise en
>forme dans un fichier XSL de transformation et comment si c'est possible ?
>
>Merci à l'avance !
>
>
>Patrick Jianxin
>
>-- Binary/unsupported file stripped by Ecartis --
>-- Type: application/octet-stream
>-- File: Tarifs.xml
>
>
>--
>Devenez redacteur <XML>fr et contribuez au developpement du
>xml francophone (http://xmlfr.org/infos/redacteurs/) !
>
>Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
>
>Cette liste est a votre disposition pour discuter en francais de
>tout sujet technique lie a XML.
>
>Pour resilier votre abonnement, envoyez un message contenant
>la commande "unsubscribe" a xml-tech-request@xmlfr.org
>(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
>
>
>
>

--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !

Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).

Cette liste est a votre disposition pour discuter en francais de tout sujet technique lie a XML.

Pour resilier votre abonnement, envoyez un message contenant la commande "unsubscribe" a xml-tech-request@xmlfr.org (mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)



Archive générée par hypermail 2.1.3 le 28/06/2004 - 11:05 UTC

webmaster@xmlfr.org

 

xml tech

Discussions techniques au sujet de XML.

Cette liste est à votre disposition pour discuter en français de tout sujet technique lié à XML.



Devenez rédacteur <XML>fr et contribuez au développement du xml francophone !
Les documents publiés sur ce site le sont sous licence "Open Content"
Conception graphique
  l.henriot@online.fr  

Conception, réalisation et hébergement