Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1080 connectés 

  FORUM HardWare.fr
  Programmation
  XML/XSL

  XSLT faire un tri sur un XML

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

XSLT faire un tri sur un XML

n°1611605
nicdudu
Posté le 14-09-2007 à 10:24:19  profilanswer
 

Bonjour à tous,
 
j'ai un petit souci avec ma feuille de style XSL:
 
Soit le XML suivant:

Code :
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. - <Annonce xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  3. - <Parution NumeroPublication="1">
  4. - <Edition NomEdition="TOTO">
  5. - <SiteDepot CodeSite="753810">
  6.    <CP No="75000" LDCPM="0" PM="0" />
  7.   <CPEM No="75000" NbEM="0" NbLDCP="0" />
  8.   <CP No="92000" LDCPM="0" PM="0" />
  9.   <CPEM No="92000" NbEM="0" NbLDCP="0" />
  10.   <CP No="93000" LDCPM="0" PM="0" />
  11.   <CPEM No="93000" NbEM="0" NbLDCP="0" />
  12.   </SiteDepot>
  13. - <SiteDepot CodeSite="750295">
  14.   <CP No="21000" LDCPM="0" PM="0" />
  15.   <CPEM No="21000" NbEM="0" NbLDCP="0" />
  16.   <CP No="45000" LDCPM="0" PM="0" />
  17.   <CPEM No="45000" NbEM="0" NbLDCP="0" />
  18.   <CP No="77000" LDCPM="0" PM="0" />
  19.   <CPEM No="77000" NbEM="0" NbLDCP="0" />
  20.   <CP No="91000" LDCPM="0" PM="0" />
  21.   <CPEM No="91000" NbEM="0" NbLDCP="0" />
  22.   <CP No="95000" LDCPM="0" PM="0" />
  23.   <CPEM No="95000" NbEM="0" NbLDCP="0" />
  24.   </SiteDepot>
  25. ...


 
Je voudrais faire en sorte que ,dans la balise CodeSite, j'obtienne les données rangées de cette manière :
 

Code :
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. - <Annonce xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  3. - <Parution NumeroPublication="1">
  4. - <Edition NomEdition="TOTO">
  5. - <SiteDepot CodeSite="753810">
  6.   <CP No="75000" LDCPM="0" PM="0" />
  7.   <CP No="92000" LDCPM="0" PM="0" />
  8.   <CP No="93000" LDCPM="0" PM="0" />
  9.   <CPEM No="75000" NbEM="0" NbLDCP="0" />
  10.   <CPEM No="92000" NbEM="0" NbLDCP="0" />
  11.   <CPEM No="93000" NbEM="0" NbLDCP="0" />
  12.   </SiteDepot>
  13. - <SiteDepot CodeSite="750295">
  14.   <CP No="21000" LDCPM="0" PM="0" />
  15.   <CP No="45000" LDCPM="0" PM="0" />
  16.    <CP No="77000" LDCPM="0" PM="0" />
  17.    <CP No="91000" LDCPM="0" PM="0" />
  18.    <CP No="95000" LDCPM="0" PM="0" />
  19.    <CPEM No="21000" NbEM="0" NbLDCP="0" />
  20.    <CPEM No="45000" NbEM="0" NbLDCP="0" />
  21.    <CPEM No="95000" NbEM="0" NbLDCP="0" />
  22.    <CPEM No="77000" NbEM="0" NbLDCP="0" />
  23.    <CPEM No="91000" NbEM="0" NbLDCP="0" />
  24.   </SiteDepot>
  25. ...


 
 
voici mon XSL :  
 

Code :
  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  3.         <xsl:template match="SiteDepot">
  4.                 <xsl:copy>
  5.                         <xsl:copy-of select="@*"/>
  6.                         <xsl:copy-of select="CP"/>
  7.                         <xsl:copy-of select="CPEM"/>
  8.                 </xsl:copy>
  9. </xsl:template>
  10. </xsl:stylesheet>


J'obtiens un tri , mais le fichier de sortie contient des lignes de "xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .
De plus, je ne sais pas comment rajouter toutes les autres balises existantes : Annonce, Parution, Edition
 
Est-cela bonne méthode ? ou dois-je faire un sort ? merci de m'aider car je suis débutant en xsl !!!
 
Merci d'avance pour votre aide !
 

mood
Publicité
Posté le 14-09-2007 à 10:24:19  profilanswer
 

n°1611727
masklinn
í dag viðrar vel til loftárása
Posté le 14-09-2007 à 17:16:22  profilanswer
 

C'est quoi l'intérêt de faire ça [:petrus dei]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1611737
nicdudu
Posté le 14-09-2007 à 17:36:33  profilanswer
 

C bon ,j'ai pu résoudre le problème ...
 
Merci quand même !!!
 
@+


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  XML/XSL

  XSLT faire un tri sur un XML

 

Sujets relatifs
Probleme de parser XML / XSLt - DoublonsSystème de template avec XML/XSLT
XSLT pour piocher dans deux docs XMLautomatiser la transformation XSLT d'un docu XML
[XML/XSLT] J'ai la solution mais je comprend rien ...En PHP, comment placer les données d'un XML dans MySQL avec XSLT ?
XML, XSLT, HTML, SVG, PDF...récupérer du contenu XML d'une fonction PHP dans une feuille XSLT ?
Editeur XML/XSLT[XML/XSLT] transformation mineure
Plus de sujets relatifs à : XSLT faire un tri sur un XML


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)