You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Luís Góis <lu...@netc.pt> on 2002/12/30 18:19:12 UTC

xsp:attribute generating a new element instead of an attribute in an already existing element

Could you comment the behaviour below :
 

XSP :
===
<dates>
 <xsp:logic>
  while(rsDates.next()) {
   <date_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
  }
  <xsp:attribute name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
 </xsp:logic>
</dates>

generated XML :
=============
<dates> 
  <date_sel>27-12-2002</date_sel> 
  <date_sel>24-12-2002</date_sel> 
  <dates current="30-12-2002"> </dates> 
</dates> 

expected XML :
=========
<dates current="30-12-2002"> 
  <date_sel>27-12-2002</date_sel> 
  <date_sel>24-12-2002</date_sel> 
</dates> 
 
 
 
TIA
Luís Góis

Re: xsp:attribute generating a new element instead of an attribute in an already existing element

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Luis,

the change of currentDate doesn't change the constraints of the API. You 
can not create an attribute after you already have created an element or 
text. If you have such a dependency you must calculate currentDate 
before creating the XML (move the logic out of the XML data structure).

Joerg

Luis Gois wrote:
> Hi.
> 
> My example wasn't good enough!:( I forgot to point out that currentDate
> might get changed in the while loop (see below), so that xsp:attribute
> must be evaluated after the java code within the xsp:logic block.
> 
> <dates>
>   <xsp:logic>
>    while(rsDates.next()) {
>     <date_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
>     if (rsDates.getString(1).equals(today) {
> 	currentDate = today;
>     }
>    }
>    <xsp:attribute
> name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
>   </xsp:logic>
> </dates>
> 
> 
> -----Original Message-----
> From: Jim Bearce [mailto:jim@bearce.us] 
> Sent: terça-feira, 31 de Dezembro de 2002 1:14
> To: cocoon-users@xml.apache.org; luisgois@netc.pt
> Subject: Re: xsp:attribute generating a new element instead of an
> attribute in an already existing element
> 
> 
> I believe you would have to do it this way:
> 
> <dates>
>     <xsp:attribute 
> name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
>     <xsp:logic>
>         while(rsDates.next()) {
>  
> <data_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
>         }
>     </xsp:logic>
> </dates>
> 
> Luís Góis wrote:
> 
> 
>>Could you comment the behaviour below :
>> 
>>
>>XSP :
>>===
>><dates>
>> <xsp:logic>
>>  while(rsDates.next()) {
>>   <date_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
>>  }
>>  <xsp:attribute
>>name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
>> </xsp:logic>
>></dates>
>>
>>generated XML :
>>=============
>><dates>
>>  <date_sel>27-12-2002</date_sel>
>>  <date_sel>24-12-2002</date_sel>
>>  <dates current="30-12-2002"> </dates>
>></dates>
>>expected XML :
>>=========
>><dates current="30-12-2002"> 
>>  <date_sel>27-12-2002</date_sel>
>>  <date_sel>24-12-2002</date_sel>
>></dates>
>> 
>> 
>> 
>>TIA
>>Luís Góis
> 
> 
> 
> 
> 
> _______________________________________________________
> Vizzavi Mail powered by Vodafone - http://www.vizzavi.pt
> Virus protected by TrendMicro - http://www.antivirus.com
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
> 
> 



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: xsp:attribute generating a new element instead of an attribute in an already existing element

Posted by Luis Gois <lu...@netc.pt>.
Hi.

My example wasn't good enough!:( I forgot to point out that currentDate
might get changed in the while loop (see below), so that xsp:attribute
must be evaluated after the java code within the xsp:logic block.

<dates>
  <xsp:logic>
   while(rsDates.next()) {
    <date_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
    if (rsDates.getString(1).equals(today) {
	currentDate = today;
    }
   }
   <xsp:attribute
name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
  </xsp:logic>
</dates>


-----Original Message-----
From: Jim Bearce [mailto:jim@bearce.us] 
Sent: terça-feira, 31 de Dezembro de 2002 1:14
To: cocoon-users@xml.apache.org; luisgois@netc.pt
Subject: Re: xsp:attribute generating a new element instead of an
attribute in an already existing element


I believe you would have to do it this way:

<dates>
    <xsp:attribute 
name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
    <xsp:logic>
        while(rsDates.next()) {
 
<data_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
        }
    </xsp:logic>
</dates>

Luís Góis wrote:

> Could you comment the behaviour below :
>  
>
> XSP :
> ===
> <dates>
>  <xsp:logic>
>   while(rsDates.next()) {
>    <date_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
>   }
>   <xsp:attribute
> name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
>  </xsp:logic>
> </dates>
>
> generated XML :
> =============
> <dates>
>   <date_sel>27-12-2002</date_sel>
>   <date_sel>24-12-2002</date_sel>
>   <dates current="30-12-2002"> </dates>
> </dates>
> expected XML :
> =========
> <dates current="30-12-2002"> 
>   <date_sel>27-12-2002</date_sel>
>   <date_sel>24-12-2002</date_sel>
> </dates>
>  
>  
>  
> TIA
> Luís Góis




_______________________________________________________
Vizzavi Mail powered by Vodafone - http://www.vizzavi.pt
Virus protected by TrendMicro - http://www.antivirus.com

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: xsp:attribute generating a new element instead of an attribute in an already existing element

Posted by Jim Bearce <ji...@bearce.us>.
I believe you would have to do it this way:

<dates>
    <xsp:attribute 
name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
    <xsp:logic>
        while(rsDates.next()) {
            <data_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
        }
    </xsp:logic>
</dates>

Luís Góis wrote:

> Could you comment the behaviour below :
>  
>
> XSP :
> ===
> <dates>
>  <xsp:logic>
>   while(rsDates.next()) {
>    <date_sel><xsp:expr>rsDates.getString(1)</xsp:expr></date_sel>
>   }
>   <xsp:attribute 
> name="current"><xsp:expr>currentDate</xsp:expr></xsp:attribute>
>  </xsp:logic>
> </dates>
>
> generated XML :
> =============
> <dates>
>   <date_sel>27-12-2002</date_sel>
>   <date_sel>24-12-2002</date_sel>
>   <dates current="30-12-2002"> </dates>
> </dates>
> expected XML :
> =========
> <dates current="30-12-2002"> 
>   <date_sel>27-12-2002</date_sel>
>   <date_sel>24-12-2002</date_sel>
> </dates>
>  
>  
>  
> TIA
> Luís Góis



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>