cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <agalla...@agssa.net>
Subject Re: use of variables on XSL
Date Tue, 18 Jan 2005 12:36:14 GMT
On Mar, 18 de Enero de 2005, 6:05, emilio leiva serrano dijo:
> Hi again!!

:-D

The looks very procedural oriented. This is not the XSLT way. I noted you
are using sql transformer. Is this correct?

>
> I'm trying to make a table of notes (idnota and nota) with request values
>
> First xsl page:
>
> ........
>
> <notas>
>     <xsl:for-each select="notas/sql:rowset/sql:row/sql:id_nota">
>       <idnota>
> 	<xsl:value-of select="."/>
>       </idnota>
>     </xsl:for-each>
>
>     <xsl:for-each select="notas/sql:rowset/sql:row/sql:nota">
>       <nota>
>          <xsl:value-of select="."/>
>       </nota>
>      </xsl:for-each>
> </notas>

you can rewrite the above code by using a new template. Is not recommended
for performance reasons the use <xsl:for-each>, because it force to read
all the node and that considerably slow down the processing. Anyway, lets
assume this is OK. ;-)

> ...........
>
> Second xsl page:
>
> <xsl:variable name="cont">1</xsl:variable>
> <xsl:variable name="valor"/>
>
>   <xsl:template match="/">
> 	<html>
> 		<body>
> 			<xsl:apply-templates />
> 		</body>
> 	</html>
>   </xsl:template>
>
>   .............
>
> <xsl:template match="notas">
> <form action="editnotas" method="get">
> <table border="1">
>     <xsl:for-each select="idnota">
>      <xsl:variable name="valor"><xsl:value-of select="."/></xsl:variable>
>      <tr>
>       <td>
>          <select name="opcion{$cont}">
> 	<option value="">Opciones</option>
>                 <option value="M-{$valor}">Modificar</option>
> 	<option value="S-{$valor}">Suprimir</option>
>          </select>
>       </td>
>       <td>
>             <xsl:value-of select="../nota[$cont]"/><xsl:value-of
> select="$cont"/>
here try to use:

<xsl:value-of select="../nota[position()]"/><xsl:value-of
select="position()"/>

>       </td>
>    </tr>
>    <xsl:variable name="cont"><xsl:value-of
> select="$cont+1"/></xsl:variable>

The above line not needed.

>    </xsl:for-each>
>
> </table>
> </form>
>   </xsl:template>
>
> .......

Here you need to try to break the <xsl:for-each> blocks. You can write the
same code without the <xsl:for-each> element.

>
>
> If I can't use <xsl:variable.... for the counter, What can I do???
>
> (BTW, this "no me friegues" sounds like Nicaraguan spanish! is n't? ;-) )
>
>    Yes, this "no me friegues" sounds like Nicaraguan spanish!!!  Your
> friend
> Thorsten told me about it, and we allways are saying it!!

lol. :-DD

Best Regards,

Antonio Gallardo.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message