Calcul quantité licence récursivement

Calcul quantité licence récursivement - XML/XSL - Programmation

Marsh Posté le 03-02-2010 à 11:33:23    

Bonjour alors voilà mon problème un XSL me permet de générer un tableau à partir d'un fichier XML
 
le tableau obtenu est de la forme suivante :
 
Code Article Désignation Quantité
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 9
VT-CS-HPUX CS for HP-UX 2
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 3
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 5
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 1
VT-CS-HPUX CS for HP-UX 1
VT-CS-ILIN CS for Intel LINUX 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 2
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 3
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 2
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 2
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 3
VT-CS-WNT CS for Windows NT/2000 2
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 2
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 1
VT-CS-WNT CS for Windows NT/2000 2
VT-CS-WNT CS for Windows NT/2000 4
VT-CS-WNT CS for Windows NT/2000 2
VT-SDS-HPUX SDS for HP-UX 1
VT-SDS-HPUX SDS for HP-UX 1
VT-SDS-HPUX SDS for HP-UX 1
VT-XVI-HPUX XVI for HP-UX 1
VT-XVI-WNT XVI for Windows NT 1
VT-XVI-WNT XVI for Windows NT 1
 
 
Voila le XSL correspondant
Code :

Code :
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3. <xsl:output encoding="ISO-8859-1" method="html"/>
  4. <xsl:param name="entreprise" />
  5. <xsl:param name="site" />
  6. <xsl:template match="Synthese">
  7.  <table width="100%" border="0" cellspacing="2" cellpadding="0">
  8.    <tr style="background-color:#e8e8e8" >
  9.     <td width="33%"><b>Code Article</b></td>
  10.     <td width="33%"><b>Désignation</b></td>
  11.     <td width="33%"><b>Quantité </b></td>
  12.    </tr>
  13.  </table>
  14.  <table width="100%" border="1" bordercolor="#e8e8e8" cellspacing="0" cellpadding="0">
  15.  <xsl:for-each select="Record">
  16.   <xsl:choose>
  17.    <xsl:when test="./CpyTrdNamDsc=$entreprise and ./CpyAddrExCde=$site">
  18.     <tr>
  19.      <td width="25%"><xsl:value-of select="ObjExCde"/></td>
  20.      <td width="25%"><xsl:value-of select="ObjDsc"/></td>
  21.      <td width="25%"><xsl:value-of select="DosQtyVal"/></td>
  22.     </tr>
  23.    </xsl:when>
  24.   </xsl:choose>
  25.  </xsl:for-each>
  26.  </table>
  27. </xsl:template>
  28. </xsl:stylesheet>


 
et un bout du XML
 
Code :

Code :
  1. <Record>
  2.   <CpyTrdNamDsc><![CDATA[SANOFI WINTHROP INDUSTRIE]]></CpyTrdNamDsc>
  3.   <CpyAddrExCde><![CDATA[QUETIGNY]]></CpyAddrExCde>
  4.   <ObjExCde><![CDATA[VT-CS-HPUX]]></ObjExCde>
  5.   <ObjDsc><![CDATA[CS for HP-UX]]></ObjDsc>
  6.   <DosQtyVal>2</DosQtyVal>
  7.   <CntExCde><![CDATA[050701.01]]></CntExCde>
  8.   <CpyInCde>1318</CpyInCde>
  9. </Record>
  10. <Record>
  11.   <CpyTrdNamDsc><![CDATA[SANOFI WINTHROP INDUSTRIE]]></CpyTrdNamDsc>
  12.   <CpyAddrExCde><![CDATA[AMBARES]]></CpyAddrExCde>
  13.   <ObjExCde><![CDATA[VT-CS-HPUX]]></ObjExCde>
  14.   <ObjDsc><![CDATA[CS for HP-UX]]></ObjDsc>
  15.   <DosQtyVal>1</DosQtyVal>
  16.   <CntExCde><![CDATA[Crt SHRR080728.01+Avt n°1]]></CntExCde>
  17.   <CpyInCde>1318</CpyInCde>
  18. </Record>
  19. <Record>
  20.   <CpyTrdNamDsc><![CDATA[SANOFI WINTHROP INDUSTRIE]]></CpyTrdNamDsc>
  21.   <CpyAddrExCde><![CDATA[AMBARES]]></CpyAddrExCde>
  22.   <ObjExCde><![CDATA[VT-CS-HPUX]]></ObjExCde>
  23.   <ObjDsc><![CDATA[CS for HP-UX]]></ObjDsc>
  24.   <DosQtyVal>9</DosQtyVal>
  25.   <CntExCde><![CDATA[Crt SHRR080728.01+Avt n°1]]></CntExCde>
  26.   <CpyInCde>1318</CpyInCde>
  27. </Record>
  28. <Record>
  29.   <CpyTrdNamDsc><![CDATA[SANOFI WINTHROP INDUSTRIE]]></CpyTrdNamDsc>
  30.   <CpyAddrExCde><![CDATA[CHILLY MAZARIN]]></CpyAddrExCde>
  31.   <ObjExCde><![CDATA[VT-CS-HPUX]]></ObjExCde>
  32.   <ObjDsc><![CDATA[CS for HP-UX]]></ObjDsc>
  33.   <DosQtyVal>1</DosQtyVal>
  34.   <CntExCde><![CDATA[050601.03]]></CntExCde>
  35.   <CpyInCde>1318</CpyInCde>
  36. </Record>
  37. <Record>
  38.   <CpyTrdNamDsc><![CDATA[SANOFI WINTHROP INDUSTRIE]]></CpyTrdNamDsc>
  39.   <CpyAddrExCde><![CDATA[MONTARGIS2]]></CpyAddrExCde>
  40.   <ObjExCde><![CDATA[VT-CS-HPUX]]></ObjExCde>
  41.   <ObjDsc><![CDATA[CS for HP-UX]]></ObjDsc>
  42.   <DosQtyVal>2</DosQtyVal>
  43.   <CntExCde><![CDATA[PC.SH070327.01(crt n°SHRR060427.01)]]></CntExCde>
  44.   <CpyInCde>1318</CpyInCde>


 
Mon but étant d'ajouter une 4ème colonne pour sommer les quantité de licence en fonction du code article.
 
J'ai bien essayer un
Code :
 

Code :
  1. <td width="25%"><xsl:value-of select="sum(preceding::DosQtyVal[../ObjExCde=current()/ObjExCde]|DosQtyVal)"/></td>


 
mais avec le <xsl:for-each select="Record"> ca marche pas bien du tout la somme récursive :/
 
Quelqu'un aurait une idée ?

Reply

Marsh Posté le 03-02-2010 à 11:33:23   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed