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

  FORUM HardWare.fr
  Programmation
  XML/XSL

  XSLT template

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

XSLT template

n°1852470
korben31
Posté le 18-02-2009 à 10:06:06  profilanswer
 

Soit mon xml:

Code :
  1. + <Results>
  2. - <RelevantResults>
  3.   <RANK>839</RANK>
  4.   <TITLE>1128-matrice vierge a010601.xls</TITLE>
  5.   <PATH>file://microsoft/img/microdob_france/dossier/fichier.xls</PATH>
  6.   <AUTHOR>TO41927</AUTHOR>
  7.   <SIZE>237568</SIZE>
  8.   <LASTMODIFIEDTIME>2008-12-21T03:09:20+01:00</LASTMODIFIEDTIME>
  9. - <HITHIGHLIGHTEDPROPERTIES>
  10. - <HHTitle>
  11.   1128-
  12.   <c0>mot clef</c0>
  13.   fichier.xls
  14.   </HHTitle>
  15. - <HHUrl>
  16. file://microsoft/img/microdob_france/
  17.   <c0>mot clef</c0>
  18.   dossier/1128-
  19.   <c0>mot clef</c0>
  20.   fichier.xls
  21.   </HHUrl>
  22.   </HITHIGHLIGHTEDPROPERTIES>
  23. - <HITHIGHLIGHTEDSUMMARY>
  24.   <c0>mot clef</c0>
  25.   blabla
  26.   <ddd />
  27.   <c0>mot clef</c0>
  28.   blablabla
  29.   <ddd />
  30.   <c0>mot clef</c0>
  31.   bla bla bla
  32.   </HITHIGHLIGHTEDSUMMARY>
  33.   </RelevantResults>
  34. - ... RelevantResults RelevantResults RelevantResults...


 
Et en faite je voudrai faire mon xslt pour mettre mon c0 en gras et remplacé ddd par ...
voila ce que j'ai ( exemple de control xslt recuperer traitement en asp.net )
 

Code :
  1. <!-- Emit a result row -->
  2.   <xsl:template match="RelevantResults">
  3.     <span class="srch-Icon">
  4.       <a href="{Path}">
  5.         <img border="0" alt="Item icon" align="absMiddle" src="html16.gif"/>
  6.       </a>
  7.     </span>
  8.     <span class="srch-Title">
  9.       <a href="{Path}">
  10.         <xsl:value-of select="Title"/>
  11.       </a>
  12.     </span>
  13.     <br/>
  14.     <div class="srch-Description">
  15.       <xsl:value-of select="Description"/>
  16.       <xsl:apply-templates mode="metadata" select="HitHighlightedSummary"/>
  17.         </div>
  18.     <p class="srch-Metadata">
  19.       <span class="srch-URL">
  20.         <a href="{Path}">
  21.           <xsl:value-of select="Path"/>
  22.         </a>
  23.       </span>
  24.       <xsl:apply-templates mode="metadata" select="Author"/>
  25.       <xsl:apply-templates mode="metadata" select="Write"/>
  26.       <xsl:apply-templates mode="metadata" select="Size"/>
  27.       <xsl:apply-templates mode="metadata" select="Rank"/>
  28.     </p>
  29.   </xsl:template>
  30.   <xsl:template match="ddd">   &#8230;  </xsl:template>
  31.  
  32.   <xsl:template match="c0">
  33.     <b>
  34.       <xsl:value-of select="."/>
  35.     </b>
  36.   </xsl:template>
  37.   <xsl:template match="c1">
  38.     <b>
  39.       <xsl:value-of select="."/>
  40.     </b>
  41.   </xsl:template>
  42.   <xsl:template match="c2">
  43.     <b>
  44.       <xsl:value-of select="."/>
  45.     </b>
  46.   </xsl:template>
  47.   <xsl:template match="c3">
  48.     <b>
  49.       <xsl:value-of select="."/>
  50.     </b>
  51.   </xsl:template>
  52.   <xsl:template match="c4">
  53.     <b>
  54.       <xsl:value-of select="."/>
  55.     </b>
  56.   </xsl:template>
  57.   <xsl:template match="c5">
  58.     <b>
  59.       <xsl:value-of select="."/>
  60.     </b>
  61.   </xsl:template>
  62.   <xsl:template match="c6">
  63.     <b>
  64.       <xsl:value-of select="."/>
  65.     </b>
  66.   </xsl:template>
  67.   <xsl:template match="c7">
  68.     <b>
  69.       <xsl:value-of select="."/>
  70.     </b>
  71.   </xsl:template>
  72.   <xsl:template match="c8">
  73.     <b>
  74.       <xsl:value-of select="."/>
  75.     </b>
  76.   </xsl:template>
  77.   <xsl:template match="c9">
  78.     <b>
  79.       <xsl:value-of select="."/>
  80.     </b>
  81.   </xsl:template>
  82.   <!-- Match and reformat date values -->
  83.   <xsl:template match="Write">
  84.     <xsl:value-of select="substring(., 9, 2)"/>/<xsl:value-of select="substring(., 6, 2)"/>/<xsl:value-of select="substring(., 1, 4)"/>
  85.   </xsl:template>
  86.   <xsl:template match="Size">
  87.     <xsl:value-of select="."/> bytes
  88.   </xsl:template>


 
en gros tout marche sauf que j'ai pas le gras et les ... pour les balise c0 et ddd ?
 :hello:  
comme je suis pas tres doué avec le xslt ... je pige pas pourquoi ca marche pas


Message édité par korben31 le 18-02-2009 à 10:07:33
mood
Publicité
Posté le 18-02-2009 à 10:06:06  profilanswer
 

n°1852590
avander
Posté le 18-02-2009 à 15:25:55  profilanswer
 

Mon moteur XSLT est sensible à la casse des élements, apparemment le tien s'en fout royalement?
 
A la ligne 16 tu sélectionne les élements HitHighlightedSummary, mais il n'y a pas de template correspondant...  
 
Il faut l'ajouter et relancer le processus pour traiter les enfants de HitHighlightedSummary:
 


<xsl:template match="HitHighlightedSummary">
  <xsl:apply-templates />
</xsl:template>


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

  XSLT template

 

Sujets relatifs
template et version des compilateursComment transformer un fichier xml en utilisant un xslt ?
xslt et phpclasse template avec pointeur membre sur la classe
template template parameterstemplate syntaxe
précision: template et inlineXSLT pour chaque fois ou le champ est different
Système de template avec XML/XSLTTemplate ou XSLT
Plus de sujets relatifs à : XSLT template


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