cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Naegeli Margrit <margrit.naeg...@ecofin.ch>
Subject RE: logic in XSL
Date Wed, 01 Nov 2000 10:53:52 GMT
You cannot put xsp logic in xsl.
 
I see two possibilities to solve your problem:
 
1) put the java counting logic in the xml and let it insert a special tag or
tag attribute after every 5 sections and make xsl turn this into a <br>
 
2) use xsl to count. I can't tell you the statements to get xsl to do this,
but I'm pretty sure that it's possible. It's quite amazing really what xsl
can do.
 
Greetings Maggie

-----Original Message-----
From: Sinvhal, Swapnil [mailto:Swapnil.Sinvhal@hpsglobal.com]
Sent: Wednesday, November 01, 2000 11:50 AM
To: 'cocoon-users@xml.apache.org'
Cc: 'greenrd@hotmail.com'
Subject: xsp:logic in XSL



Hi, Cocoon - users !! 

I am trying to  apply the <xsp:logic> tag in XSL. 
But the generated HTML shows up the JAVA code as such - it does not process
it. 

I have to display a list of sections. 
After every 5 sections , I need a <BR> tag. 

What am I doing wrong ? 

====================== 
THE XML file is : 

<?xml version="1.0"?> 
<!-- Author: Swapnil Sinvhal --> 
<?cocoon-process type="xsp"?> 
<?cocoon-process type="xslt"?> 
<?cocoon-format type="text/xml"?> 
<?xml-stylesheet type="text/xsl" href="SectionLinks.xsl"?>  
<xsp:page language="java" xmlns:xsp=" http://www.apache.org/1999/XSP/Core
<http://www.apache.org/1999/XSP/Core> "> 
        <sections> 
        <xsp:logic>     
                String linkData = null; 
                String hrefData = null; 
                String linkKey = null; 
                String hrefKey = null; 
                int i =0; 
                for(i=1; ; i++) 
                { 
                  linkKey = "sectionLink." + i; 
                  hrefKey = "ahrefLink." + i;                     
                  linkData=
(String)(((Hashtable)request.getAttribute("data")).get(linkKey)); 
                  hrefData =
(String)(((Hashtable)request.getAttribute("data")).get(hrefKey)); 
                  
                  if ((hrefData==null)||(linkData==null)) break;

                  if (!(hrefData.equals(""))) 
                    { 
                       <section> 
 
<sectionLink><xsp:expr>linkData</xsp:expr></sectionLink>  
                        <ahrefLink><xsp:expr>hrefData</xsp:expr></ahrefLink>

                       </section> 
                    } 
                } 
        </xsp:logic> 
</sections> 
</xsp:page> 

============================== 


The XSL file is : 

****************************** 
<xsl:template match="/">  
   <table align="left" height="100%" width="100%" cellpadding="0"
cellspacing="0"> 
        <tr align="left" valign="top" class="tdc" height="100%" width="70%">

          <td CLASS="cityBkgd"> 
          
             <xsp:logic> 
                 <![CDATA[ 
                      private int count = 0;  
                  ]]> 
                        <xsl:for-each select="sections/section">        
                 <xsp:logic> 
                    <![CDATA[ 
                        count += 1; 
                        if (count==5) 
                        { 
                    ]]> 
                 </xsp:logic> 
                        <BR /> 
                 <xsp:logic> 
                    <![CDATA[ 
                        } 
                        else 
                        { 
                   ]]> 
                 </xsp:logic> 
                   <xsl:element name = "A"> 
                        <xsl:attribute name = "id"> 
                                SectionLink 
                        </xsl:attribute>  
                        <xsl:attribute name = "href"> 
                                <xsl:value-of select="ahrefLink"/>  
                        </xsl:attribute>  
                        <B>                     
                                <xsl:value-of select="sectionLink"/> 
                        </B>                            
                   </xsl:element>       
                 <xsp:logic> 
                    <![CDATA[ 
                        } 
                      ]]> 
                </xsp:logic> 
                   <font color = "#ffffff" size = "2" face = "Arial"> 
                        <B>&#160;&#160;|&#160;&#160;</B> 
                   </font> 
                </xsl:for-each> 
                </xsp:logic> 
            </td> 
            <td align="left" valign="top" class="tdc" height="100%"
width="30%"> 
                 &#160;&#160; 
            </td> 
          </tr> 
   </table> 
</xsl:template> 
</xsp:page> 
</xsl:stylesheet>   

************************************************************* 


Thanks a lot. 

Regards, 
Swapnil 


Mime
View raw message