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

  FORUM HardWare.fr
  Programmation
  XML/XSL

  XSLT - Transformation d'un fichier XML

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

XSLT - Transformation d'un fichier XML

n°1645672
Giz
Posté le 20-11-2007 à 10:59:09  profilanswer
 

mail-xsl.xml :
 

Code :
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns="http://www.w3.org/TR/REC-html40">
  5. <xsl:output method="html" encoding="UTF-8"
  6.  doctype-public="-//W3C//DTD HTML 4.01//EN"
  7.  doctype-system="http://www.w3.org/TR/html4/strict.dtd" indent="yes" />
  8. <xsl:template match="/">
  9.  <html xmlns="http://www.w3.org/1999/xhtml">
  10.   <head>
  11.    <meta http-equiv="Content-Type"
  12.     content="text/html; charset=UTF-8" />
  13.    <title>ARGUS - Dealer Request</title>
  14.   </head>
  15.   <body>
  16.    <table border="0">
  17.     <xsl:apply-templates select="subject" />
  18.    </table>
  19.   </body>
  20.  </html>
  21. </xsl:template>
  22. <xsl:template match="subject">
  23.  <tr align="left">
  24.   <th>SUBJECT:</th>
  25.   <td>
  26.    <xsl:value-of select="." />
  27.   </td>
  28.  </tr>
  29. </xsl:template>
  30. </xsl:stylesheet>


 
mail.xml :
 
 

Code :
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mail>
  3. <subject>Submit</subject>
  4. <body>
  5.  <description>
  6.   <correspondent>
  7. ...


 
mail.html désiré :

Code :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>ARGUS - Request For Incident</title>
  6. </head>
  7. <body>
  8. <table border="0">
  9. <tr align="left">
  10.  <th>SUBJECT:</th>
  11.  <td>Submit</td>
  12. </tr>
  13. ...


 
Résultat HTML obtenu :
 

Code :
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <title>ARGUS - Dealer Request</title></head><body><table border="0"></table></body></html>


 
 
Le

Code :
  1. <xsl:template match="subject">

n'est pas execute pourquoi ? Le contenu de <table></table> est vide :(.


Message édité par Giz le 20-11-2007 à 11:00:23

---------------
Asus P5Q Pro | C2D E8400 3GHz@4GHz + Noctua NH-C12P | 2x2Go Patriot Extreme PC-8500 | GeForce GTX 460@Stock 1Go GLH | Crucial SSD M4 64Go Sata3
mood
Publicité
Posté le 20-11-2007 à 10:59:09  profilanswer
 

n°1645675
Giz
Posté le 20-11-2007 à 11:02:45  profilanswer
 

J'ai trouvé :) : Il faut remplacer  
 

Code :
  1. <xsl:apply-templates select="subject" />


 
par  
 

Code :
  1. <xsl:apply-templates select="/mail/subject" />


---------------
Asus P5Q Pro | C2D E8400 3GHz@4GHz + Noctua NH-C12P | 2x2Go Patriot Extreme PC-8500 | GeForce GTX 460@Stock 1Go GLH | Crucial SSD M4 64Go Sata3

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

  XSLT - Transformation d'un fichier XML

 

Sujets relatifs
Tester /récupérer date de derniere modif fichierLire un tableau de valeurs dans un fichier contenant aussi du texte
[Fichier TXT] ajouter un caractère à la fin de chaque ligneImporter fichier Excel dans Outlook
[PHP] Upload de fichier en plusieurs parties[ FLASH ] Qu'est ce qu'un fichier MXP ?
recherche dans un fichier commande lunixouvrir un fichier en J2ME
Ouvrir un fichier excel en focntion de son indiceFormulaire : envoi de mail et upload de fichier en un coup
Plus de sujets relatifs à : XSLT - Transformation d'un fichier XML


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR