probleme xsl/javascript

probleme xsl/javascript - HTML/CSS - Programmation

Marsh Posté le 19-07-2006 à 08:46:02    

Bonjour à tous,
 
j'ai un petit problème avec un fichier xsl dans lequel je veux utiliser du javascript.
Je n'arrive pas à transmettre des valeurs récupérées pas <xsl:value-of ...> comme arguments
à une fonction javascript le tout à l'intérieur d'une boucle xsl. La balise <script ..>
annule l'element courant du <xsl:for-each...> donc la récupération en relatif ne fonctionne
plus !!!  
Quelqu'un connait-il un moyen de contourner ce problème ?
Merci d'avance pour vos réponses.
 
 
détail du code xsl:
 
   <xsl:for-each select="//row">
      <script type="text/javascript">
         var site = <xsl:value-of select="./row_element[@column=1]"/>
         var rev  = <xsl:value-of select="./row_element[@column=2]"/>
         writeArrayTitle(site,rev)
      </script>
   </xsl:for-each>
 
 
détail du code js (dans le <head> du xsl) :
 
   <script type="text/javascript">
      function writeArrayTitle(name,rev) {
         /* divers tests... */
         document.write(name + "/" + rev + "<br/>" )
      }
   </script>
 
 
détail du xml :
   <row>
      <object_tag tag="4628" uid="gxHRqPncXWSHFB"/>
      <object_tag tag="4667" uid="QdNRqPncXWSHFB"/>
      <row_element column="0" component_tag="4664" property_name="Affaire">0278018</row_element>
      <row_element column="1" component_tag="4628" property_name="object_name">site01</row_element>
      <row_element column="2" component_tag="4628" property_name="item_revision_id">A</row_element>
      <row_element column="3" component_tag="4657" property_name="object_name">ligne01</row_element>
      <row_element column="4" component_tag="14710" property_name="item_revision_id">A</row_element>
      <row_element column="5" component_tag="14716" property_name="object_name">zone0101</row_element>
      <row_element column="6" component_tag="14849" property_name="item_revision_id">A</row_element>
      <row_element column="7" component_tag="14855" property_name="object_name">ilot010101</row_element>
      <row_element column="8" component_tag="14860" property_name="item_revision_id">A</row_element>
      <row_element column="9" component_tag="14866" property_name="object_name">POSTE_11100001</row_element>
      <row_element column="10" component_tag="14871" property_name="item_revision_id">A</row_element>
      <row_element column="11" component_tag="14876" property_name="item_id">PSE_000003</row_element>
      <row_element column="12" component_tag="14880" property_name="item_revision_id">A</row_element>
      <row_element column="13" component_tag="14884" property_name="object_name">p3</row_element>
      <row_element column="14" component_tag="14890" property_name="NumeroProduit">8200000129</row_element>
      <row_element column="15" component_tag="14887" property_name="item_id">VEH_000129</row_element>
      <row_element column="16" component_tag="14890" property_name="Indice">0_02_0002</row_element>
      <row_element column="17" component_tag="14888" property_name="name">TCM Released</row_element>
      <row_element column="18" component_tag="14887" property_name="item_revision_id">A</row_element>
   </row>
   .
   .
   .
   <row>
      <object_tag tag="4628" uid="gxHRqPncXWSHFB"/>
      <object_tag tag="4667" uid="QdNRqPncXWSHFB"/>
      <row_element column="0" component_tag="4664" property_name="Affaire">0278018</row_element>
      <row_element column="1" component_tag="4628" property_name="object_name">site01</row_element>
      <row_element column="2" component_tag="4628" property_name="item_revision_id">A</row_element>
      <row_element column="3" component_tag="4657" property_name="object_name">ligne01</row_element>
      <row_element column="4" component_tag="14710" property_name="item_revision_id">A</row_element>
      <row_element column="5" component_tag="14716" property_name="object_name">zone0101</row_element>
      <row_element column="6" component_tag="14849" property_name="item_revision_id">A</row_element>
      <row_element column="7" component_tag="14855" property_name="object_name">ilot010101</row_element>
      <row_element column="8" component_tag="14860" property_name="item_revision_id">A</row_element>
      <row_element column="9" component_tag="14866" property_name="object_name">POSTE_11100001</row_element>
      <row_element column="10" component_tag="14871" property_name="item_revision_id">A</row_element>
      <row_element column="11" component_tag="14876" property_name="item_id">PSE_000003</row_element>
      <row_element column="12" component_tag="14880" property_name="item_revision_id">A</row_element>
      <row_element column="13" component_tag="14885" property_name="object_name">p1</row_element>
      <row_element column="14" component_tag="14895" property_name="NumeroProduit">8200000127</row_element>
      <row_element column="15" component_tag="14893" property_name="item_id">VEH_000127</row_element>
      <row_element column="16" component_tag="14895" property_name="Indice">0_02_0002</row_element>
      <row_element column="17" component_tag="14893" property_name="release_status_list"> </row_element>
      <row_element column="18" component_tag="14893" property_name="item_revision_id">A</row_element>
   </row>

Reply

Marsh Posté le 19-07-2006 à 08:46:02   

Reply

Marsh Posté le 19-07-2006 à 09:35:09    

question bète pour commencer: c'est quoi l'intéret de générer du javascript qui va ecrire de l'html ???
Pourquoi tu génères pas de l'html directement ( les tests tu pourrais les faire dans ta xsl)???

Reply

Marsh Posté le 19-07-2006 à 09:56:25    

c'est vrai que je n'ai pas expliqué le but du dev !!!
le javascript est utilisé pour n'écrire qu'une seule fois le contenu des balises <row_element column="1"..> et <row_element column="2"..>
le contenu de ces balises me sert à écrire le titre d'un tableau.
dans l'exemple, je ne doit écrire qu'une seule fois "site01/A", mais si je rencontre une balise qui porte un autre nom par exemple site02, je dois creer un autre tableau avec le titre "site02/A"
en fait, je cherche à détecter les doublons.
c plus clair ?

Reply

Marsh Posté le 19-07-2006 à 10:37:15    

oui c'est plus clair, mais ma question reste fort pértinante... Pourquoi  tu detectes pas les doublons en xslt plutot que de te faire chier avec du js?

Reply

Marsh Posté le 19-07-2006 à 10:39:29    

tout simplement parce que je n'ai pas réussi à le faire en xslt :o(

Reply

Marsh Posté le 19-07-2006 à 10:43:57    

Reply

Marsh Posté le 19-07-2006 à 10:54:57    

merci beaucoup pour ton aide, j'essaye ça tout de suite...

Reply

Sujets relatifs:

Leave a Replay

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