[xsl] xsl function position() used to fill attribute "name" in input HTML tags

Subject: [xsl] xsl function position() used to fill attribute "name" in input HTML tags
From: Laurence Mossuz <mossuz@xxxxxxxxxxxxx>
Date: Thu, 13 Mar 2003 10:31:41 +0100
hello everybody,

my xml file is like this

<test>
  <toto>
    <titi>ti1</titi>
    <tata>ta1</tata>
  </toto>
  <toto>
    <titi>ti2</titi>
  </toto>
  <toto>
    <tata>ta3</titi>
  </toto>
  <toto/>
</test>

and a part of my xsl file is like this

   <xsl:for-each select="toto">
    <tr>
     <td>
      <xsl:choose>
       <xsl:when test="string(titi)">
        <xsl:value-of select="titi"/>
       </xsl:when>
       <xsl:otherwise>
        <input name="titi{position()}" type="text"/>
       </xsl:otherwise>
      </xsl:choose>
    </td>
    <td>
     <xsl:choose>
      <xsl:when test="string(tata)">
       <xsl:value-of select="tata"/>
      </xsl:when>
      <xsl:otherwise>
       <input name="tata{position()}" type="text"/>
      </xsl:otherwise>
     </xsl:choose>
    </td>
   </tr>
  </xsl:for-each>

i just want to be sure that tata{position()} is equal to the position of

the node tata in the xml document.
Besides, if i want to define the "name" attribute as the concatenation
of a string, test/toto/tata,  and the tata{position()}result, is it
correct to write

<input name="test/toto/tata+tata{position()}" type=text"}?

many thanks for your help!

Miss Laurence Mossuz



--

Laurence MOSSUZ

LAPP Service Informatique
Chemin de Bellevue BP 110
74941 Annecy-Le-Vieux CEDEX
Tel : 04 50 09 17 31 _ Fax : 04 50 27 94 95



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread