You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Neeme Praks <ne...@one.lv> on 2000/06/04 23:02:14 UTC

recursive func in XSP?

Is it possible to write recursive functions in XSP that would return
XML?

I have a tree-like object structure in Java and I want to convert it to
tree structure in XML.
I have an implementation of this in ECS, now I'm porting my stuff over
to XSP and want to output XML instead of ECS elements.
The function is in the beginning of my XSP page.

Otherwise everything is pretty straight-forward, but what type should my
function return so the resulting XML fragment would be included in the
main XML doc?

As I'm just starting out with XSP, any pointers in the right direction
appreciated.
(I know the links to the new and old XSP tutorials, but this was not
included there)

Neeme

Re: recursive func in XSP?

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sun, 4 Jun 2000, Mike Engelhart wrote:

> on 6/4/00 9:58 PM, Mike Engelhart at mengelhart@earthtrip.com wrote:
> 
> >> or, even simpler:
> >> 
> >> <xsp:expr>yourMethodCall()</xsp:expr>
> >> 
> >> - donald
> > I thought that would give a parent document error unless you pass the page's
> > Document object into the method...
> > 
> > mike
> which actually mine would do as well :-)
> 
> it should be
> Element e = yourMethodCall();
> xspCurrentNode.appendChild(document.importNode(e));

6 of one, 1/2 dozen of the other. i guess i just don't like relying on
XSP's built in and not documented very well variables.

- donald


Re: recursive func in XSP?

Posted by Mike Engelhart <me...@earthtrip.com>.
on 6/4/00 9:58 PM, Mike Engelhart at mengelhart@earthtrip.com wrote:

>> or, even simpler:
>> 
>> <xsp:expr>yourMethodCall()</xsp:expr>
>> 
>> - donald
> I thought that would give a parent document error unless you pass the page's
> Document object into the method...
> 
> mike
which actually mine would do as well :-)

it should be
Element e = yourMethodCall();
xspCurrentNode.appendChild(document.importNode(e));


Mike


Re: recursive func in XSP?

Posted by Mike Engelhart <me...@earthtrip.com>.
on 6/4/00 9:49 PM, Donald Ball at balld@webslingerZ.com wrote:

> or, even simpler:
> 
> <xsp:expr>yourMethodCall()</xsp:expr>
> 
> - donald
I thought that would give a parent document error unless you pass the page's
Document object into the method...

mike


Re: recursive func in XSP?

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sun, 4 Jun 2000, Mike Engelhart wrote:

> on 6/4/00 5:25 PM, Donald Ball at balld@webslingerZ.com wrote:
> 
> > org.w3c.dom.Node should work fine.
> Element is fine too. Then in your XSP, use this:
> 
> Element e = yourMethodCall();
> xspCurrentNode.appendChild(e);

or, even simpler:

<xsp:expr>yourMethodCall()</xsp:expr>

- donald


Re: recursive func in XSP?

Posted by Mike Engelhart <me...@earthtrip.com>.
on 6/4/00 5:25 PM, Donald Ball at balld@webslingerZ.com wrote:

> org.w3c.dom.Node should work fine.
Element is fine too. Then in your XSP, use this:

Element e = yourMethodCall();
xspCurrentNode.appendChild(e);

Mike


Re: recursive func in XSP?

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sun, 4 Jun 2000, Neeme Praks wrote:

> 
> Is it possible to write recursive functions in XSP that would return
> XML?
> 
> I have a tree-like object structure in Java and I want to convert it to
> tree structure in XML.
> I have an implementation of this in ECS, now I'm porting my stuff over
> to XSP and want to output XML instead of ECS elements.
> The function is in the beginning of my XSP page.
> 
> Otherwise everything is pretty straight-forward, but what type should my
> function return so the resulting XML fragment would be included in the
> main XML doc?

org.w3c.dom.Node should work fine.

- donald


Re: recursive func in XSP?

Posted by Mike Engelhart <me...@earthtrip.com>.
on 6/4/00 4:02 PM, Neeme Praks at neeme@one.lv wrote:

> Is it possible to write recursive functions in XSP that would return
> XML?
What is the input to this function going to be?  String, Object, Map??