cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: recursive func in XSP?
Date Mon, 05 Jun 2000 12:12:12 GMT
Neeme Praks wrote:
> 
> > -----Original Message-----
> > From: Giacomo Pati [mailto:Giacomo.Pati@pwr.ch]
> > Sent: Monday, June 05, 2000 10:18 AM
> > To: cocoon-dev@xml.apache.org
> > Subject: Re: recursive func in XSP?
> >
> >
> > Neeme Praks wrote:
> > >
> > > Thanks for all your valuable suggestions! I'll try them out
> > and will let
> > > you know if I managed to solve my problem.
> > >
> > > Just one more concern: if I use DOM objects, I'm incompatible with
> > > cocoon2, right?
> > > Or is there something that I missed along the way...
> >
> > You mean in an XSP page? If you use standard xsp tags this
> > should be not
> > problem. If you use things like
> >
> >  Element e = yourMethodCall();
> >  xspCurrentNode.appendChild(document.importNode(e));
> 
> But how can I achieve this kind of recursiveness only by using standard
> stuff?
> To illustrate, I'll include my current code. It doesn't compile properly
> yet, but should give you an idea what I want to achieve.
> 
> Neeme
> 
> Sorry for the tabs, I haven't figured out how to force XMLSpy to use
> spaces instead of tabs...
> ----------- code, cut here -------------------
> <?xml version="1.0"?>
> <?cocoon-process type="xsp"?>
> <xsp:page language="java"
> xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>         <xsp:structure>
>                 <xsp:include>diweb.bo.*</xsp:include>
>                 <xsp:include>org.w3c.dom.*</xsp:include>
>         </xsp:structure>
>         <xsp:logic><![CDATA[
>                 private String normalize(String string)
>                 {
>                         if (string == null) return "";
>                         else return string;
>                 }
> 
>                 private Node BuildTree( Document doc, FolderTree tree,
> long SelectedID, long RemovedID ) throws Exception
>                 {
>                         if ( tree == null )
>                         {
>                                 return null;
>                         }
>                         Folder folder = tree.getRoot();
>                         long ID = folder.getId();
>                         if (ID == RemovedID)
>                                 return null;
> 
>                         Node result = doc.createElement("folder");
>                         result.appendChild(
> doc.createAttribute("folderID") ).setNodeValue( String.valueOf(ID) );
>                         if (ID == SelectedID)
>                                 result.appendChild(
> doc.createAttribute("IsSelected") ).setNodeValue("1");
>                         result.setNodeValue( folder.getName() );
> 
>                         if (tree.getNodes() != null)
>                         {
>                                 for (int i = 0; i <
> tree.getNodes().length; i++)
>                                 {
>                                         result.appendChild ( BuildTree(
> doc, tree.getNodes()[i], SelectedID, RemovedID ) );
>                                 }
>                         }
> 
>                         return result;
>                 }
> 
>                 int UserID = 1;
>         ]]></xsp:logic>
>         <page>
>                 <title>Test XSP Page</title>
>                 <xsp:logic>
>                         FolderTree tree =
> FolderUtility.getTreeByUser(UserID, UserID);
>                         Node node = BuildTree( document, tree, 0, 0);
> 
> xspCurrentNode.appendChild(document.importNode(node, true));
>                 </xsp:logic>
>         </page>
> </xsp:page>

can't you simply use

<xsp:expr>BuildTree(document, tree, 0, 0)</xsp:expr>

?

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<stefano@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Mime
View raw message