cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robby.pelss...@vodafone.com
Subject RE: loops in XSP
Date Wed, 18 Aug 2004 11:55:05 GMT
Here is an example that produces input for a chart... and makes use of while
loop
 
<xsp:page 
  language="java" 
  xmlns:xsp=" http://apache.org/xsp <http://apache.org/xsp> ">
 
  <xsp:structure>
    <xsp:include>java.sql.*</xsp:include>
    <xsp:include>java.lang.Math</xsp:include>
    <xsp:include>java.util.*</xsp:include>
    <xsp:include>java.text.DateFormat</xsp:include>
  </xsp:structure>
 

  <chart>
  <xsp:logic>
    boolean validnumberoflines = false;
    boolean resultfound = false;
    boolean negativevalues = false;
    double maxvalue = 38;
    double minvalue = -25;
    double range;
    double step2 =0;
    double step3 =0;
    double step4 =0;
    double step5 =0;
    double step6 =0;
    double step7 =0;
    double maxpref =0;
    double minpref =0;
    double numberoflinestotal =0;
    int i =10;
    double uppervalidation = 1.20;
    if (minvalue &lt;0) {
        range= maxvalue - minvalue;
        minvalue = - minvalue;
        negativevalues = true; 
    } else {
        range = maxvalue;
    }
    
    while (!resultfound &amp;&amp; uppervalidation &lt; 1.50) {
        uppervalidation = uppervalidation + 0.025;
        i = 10; 
        while ( i  &gt; 0 &amp;&amp; !resultfound) {
            step2 = (range* 1.15) / i; 
            step3 = Math.log((range* 1.15) / i) / Math.log(10);
            step4 = Math.floor(Math.log((range* 1.15) / i) / Math.log(10))
-1;
            step5 = Math.floor(((range* 1.15) / i) /
Math.pow(10,(Math.floor(Math.log((range* 1.15) / i) / Math.log(10)) -1)));
            if (10 &lt;= step5 &amp;&amp; step5 &lt;= 14) {
                  step6 = 10 * Math.pow(10,step4);
            } 
            if (14 &lt; step5 &amp;&amp; step5 &lt;= 35) {
                  step6 = 20 * Math.pow(10,step4);
            } 
            if (35 &lt; step5 &amp;&amp; step5 &lt;= 75) {
                  step6 = 50 * Math.pow(10,step4);
            } 
            if (75 &lt; step5 &amp;&amp; step5 &lt;= 100) {
                  step6 = 100 * Math.pow(10,step4);
            } 
            step7 = i * step6;
            if (1.05 * range&lt;= step7 &amp;&amp; step7 &lt;=
(uppervalidation * range)) {
                 validnumberoflines = true;
                 resultfound = true;
            } else {
                validnumberoflines = false;    
            } 
            i = i - 1; 
        } 
    }    
 
    while (maxpref &lt;= maxvalue ) {
        maxpref = maxpref + step6;          
    } 
    while (negativevalues &amp;&amp; minpref &lt;= minvalue  ) {
        minpref = minpref + step6;
    }
    numberoflinestotal = ((maxpref + minpref) / step6) + 1;
        
 
  </xsp:logic>
 
     <parameters>
      <canvaswidth>700</canvaswidth>
      <canvasheight>500</canvasheight>
      <title>Title of chart </title>
      <view>column</view>  // possible views are column, bar, pie .....
      <xaxis>
        <label>Priority</label>
      </xaxis>
      <yaxis>
        <label># Tickets</label>
        <xsp:logic>
          for (int teller = 1; teller &lt;= numberoflinestotal; teller++) {
              <xsp:content>  
                <line/>
              </xsp:content>
          } 
        </xsp:logic>
      </yaxis> 
      <legend>
        <visible>true</visible> 
        <series>
          <label>Open at Start</label>
          <label>Started</label>
          <label>Completed</label>
          <label>Open at end</label>
        </series>
      </legend>
    </parameters>
    
    <data>
      <label>Z</label>
      <value>12</value>
      <value>10</value>
      <value>6</value>
      <value>16</value>
    </data>
    <data>
      <label>M</label>
      <value>-25</value>
      <value>10</value>
      <value>20</value>
      <value>15</value>
    </data>
    <data>
      <label>L</label>
      <value>38</value>
      <value>-12</value>
      <value>23</value>
      <value>23</value>
    </data> 
    <data>
      <label>?</label>
      <value>4</value>
      <value>13</value>
      <value>8</value>
      <value>9</value>
    </data>
 
    <range><xsp:expr>range</xsp:expr></range>
    <minpref><xsp:expr>minpref</xsp:expr></minpref>
    <stepvalue><xsp:expr>step6</xsp:expr></stepvalue>
  </chart>

</xsp:page>


-----Original Message-----
From: Perez Carmona, David [mailto:DPerezCar@fcc.es]
Sent: 18 August, 2004 13:33
To: users@cocoon.apache.org
Subject: RE: loops in XSP


Yes they can, give us an example of your code.

-----Mensaje original-----
De: Jones A [mailto:jones_a@sify.com]
Enviado el: miƩrcoles, 18 de agosto de 2004 13:58
Para: users@cocoon.apache.org
Asunto: loops in XSP


Can loops such as while loop and for loop be used in java in XSP?



I get the error



\"The content of elements must consist of well-formed character data or
markup.\"


 
<http://ads.sify.com/RealMedia/ads/click_nx.ads/mail.sify.com/sentmail@Botto
m>  
************************************************************* Este correo ha
sido procesado por el antivirus del Grupo FCC.
************************************************************* 	

************************************************************* Este correo ha
sido procesado por el antivirus del Grupo FCC.
************************************************************* 	


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


Mime
View raw message